In a WinForms environment, I want to wait a specified amount of time before hiding a user control, but I don't want to freeze the entire UI. I can't kick off to another thre开发者_如何转开发ad because I have to service the UI components on the thread they were created on. What is the cleanest way to do this?
I would use a System.Windows.Forms.Timer. The Tick
event will execute on the UI (message loop) thread.
Starting a second thread for this works fine as long as you use Invoke
to communicate with the form from your thread.
However, the best way would be to use a Timer
.
精彩评论