1
我正在寫一個應用程序[net/wpf/c#],它應該測量用戶在聽到單詞後點擊(響應)的速度。它被稱爲聽覺處理速度測試(PST),人類的平均速度大約爲70-140ms。爲了瞭解生成的事件的精確性,我寫了以下內容。實時測量鼠標點擊間隔
public partial class MainWindow : Window
{
System.Diagnostics.Stopwatch w = new System.Diagnostics.Stopwatch();
public MainWindow() { InitializeComponent(); }
private void textBlock1_PreviewMouseDown (object sender, MouseButtonEventArgs e)
{
e.Handled = true;
w.Stop();
System.Diagnostics.Debug.WriteLine(w.ElapsedMilliseconds);
w.Reset(); w.Start();
}
private void Grid_KeyDown (object sender, KeyEventArgs e)
{
e.Handled = true;
w.Stop();
System.Diagnostics.Debug.WriteLine(w.ElapsedMilliseconds);
w.Reset(); w.Start();
}
}
private void Application_Startup (object sender, StartupEventArgs e)
{
Process thisProc = Process.GetCurrentProcess();
thisProc.PriorityClass = ProcessPriorityClass.RealTime;
ProcessThreadCollection myThreads = thisProc.Threads;
foreach (ProcessThread pt in myThreads) {
pt.PriorityLevel = ThreadPriorityLevel.TimeCritical;
}
}
我可以點擊最快的是100毫秒左右,如果保持壓下鍵盤鍵再往下我坐下來的響應時間30毫秒。有什麼辦法可以讓它變得更快嗎? TIA
PS:我的keyboad重複間隔設置爲最高。 – user109134 2010-11-18 01:42:39