我有 Silverlight 库项目,其中包含大量控件。
我想将某个时间点的 PC 计时器分辨率降低到 5 毫秒。
我尝试使用 NtQueryTimerResolution 但出现异常:
Attempt by security transparent method SetupTimer() to call native code through method
NtQueryTimerResolution(UInt32 ByRef, UInt32 ByRef, UInt32 ByRef) failed. Methods must be
security critical or security safe-critical to call native code.
设置计时器方法具有安全属性..所以我不明白有什么问题...
[SecuritySafeCritical]
private void SetupTimer()
{
uint resolution = 0;
NtSetTimerResolution(50000, true, ref resolution);
}