开发者

Background thread vs UI thread

开发者 https://www.devze.com 2023-02-20 07:25 出处:网络
Could any one he开发者_如何转开发lp me to figure out background thread and UI thread in C#.I have googled it but i coudnt find article illustrate both.A UI thread creates UI elements and waits and res

Could any one he开发者_如何转开发lp me to figure out background thread and UI thread in C#.I have googled it but i coudnt find article illustrate both.


A UI thread creates UI elements and waits and responds to events like mouse clicks and key presses. You can only access the UI elements from the UI thread.

There are two types of threads: background and foreground. A UI thread is an example of a foreground thread.

The difference between background and foreground threads is pretty simple. Background threads don't stop a process from terminating, but foreground threads do. When the last foreground thread stops, then all the background threads are also stopped and the process ends.


This website has a lot of information about threading as well as parallel programming: http://www.albahari.com/threading/

Good luck


There is another key issue to keep in mind. There is a single U.I. thread and you can only call methods on U.I. objects in that thread. In another thread you need to call Control.Invoke() to flip to the U.I. thread if you are doing something like update a status bar.

0

精彩评论

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