开发者

Change label text after Thread.Sleep

I have a sign in system running at my school, and when a student signs in, it shows a welcome message and after 5 seconds, this welcome message is erased to be replaced by, "Please swipe your studen开发者_开发百科t card". I have a sleep thread running. I want the welcome label to reset to say "Please swipe your ID card" after the sleep thread has finished, but it won't do it. Any help? Am I going about this the right way? Thank you.


You haven't given any details so we need to guess at the exact cause of the problem. I'm going to assume that you are using C# on Windows.

I'd guess that you are trying to perform user interface code from a worker thread which is an error. User interface code should run in the main thread.

Whilst this could be solved with Control.Invoke a much better approach is to avoid any threads, use a timer for your 5 second wait and perform the UI update in the main thread.


Which language? Whats your code ?

You could also use a timer and assign a new text to the label when the timer ticks.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜