Is only the UI-thread able to display to the screen, or can other threads do this as well?
Asked
Active
Viewed 130 times
4
-
FYI: You can have more than one UI thread in a process. – Brian Rasmussen May 19 '11 at 18:20
-
@Brian: Where can I learn about this? I didn't know there was more than one UI thread . . . – richard May 19 '11 at 18:23
-
1.NET restricts access to GUI controls to the STA thread that created them. You can create other STA threads with their own set of controls. – Brian Rasmussen May 19 '11 at 18:27
3 Answers
7
No you can only access to UI directly from the UI thread but you can marshal the results from other threads, such as using the Control.Invoke or control.BegineInvoke/EndInvoke
Check this out

Phil Murray
- 6,396
- 9
- 45
- 95
1
You can use the BeginInvoke()
member of all GUI controls to change the values of their properties from background threads.
If you are using a backgroundworker you could use the ReportProgress
event, which is even easier.

Mr47
- 2,655
- 1
- 19
- 25
0
also Depends if you are using WinForms or WPF, in Winforms you use Control.Invoke and in WPF you use Dispatcher class. WPF has more sophisticated thread UI dispatcher

Bek Raupov
- 3,782
- 3
- 24
- 42