开发者

Sleep thread before hiding control in WinForms?

开发者 https://www.devze.com 2023-03-15 12:42 出处:网络
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 becau

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.

0

精彩评论

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