Background thread vs UI thread

拥有回忆 提交于 2020-02-01 03:24:24

问题


Could any one help me to figure out background thread and UI thread in C#.I have googled it but i coudnt find article illustrate both.


回答1:


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.




回答2:


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

Good luck




回答3:


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.



来源:https://stackoverflow.com/questions/5471626/background-thread-vs-ui-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!