开发者

C# exam application timer cheating issue [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I have made an exam application in C# that has a timer, while taking exam suppose the candidate keeps on pressing th开发者_如何学Pythone windows' minimize button (without releasing the mouse) at 1 minute and 30 seconds, the time pauses even if the candidate keeps on pressing the mouse for 10 minutes, but when the mouse is released the time resumes from the very second where it was paused i.e. 1 minute and 30 seconds. I want the timer to be continued without any pauses.


What timer component are you using? System.Windows.Forms.Timer or System.Threading.Timer?

I suspect the S.W.F.Timer uses SetTimer API call which uses window messages which would explain what you are seeing, a threaded timer would be better.

You could also just use a thread, store a DateTime.UtcNow and every 100ms or something in the thread, get another DateTime.UtcNow and check the TimeSpan for the elapsed time.


Use the System.Threading.Timer class because that is supposed to work independently from windows messages


You could record the DateTime.UtcNow when the test starts and monitor that DateTime.UtcNow - startTime in the Elapsed event of a timer. If the difference is greater than you want, you can end the test there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜