Why is WaitAll method not supported for threads that have STAThreadAttribute?

This msdn article says:

The WaitAll method is not supported for threads that have STAThreadAttribute.

If one googles or searches for stackoverflow, they will find numerous workarounds.

I would like to know the reason why this is not supported. Of course, this is not arbitrary, and there is a good reason why this may be so. What happens to an STA thread that prevents or makes it difficult to do WaitAllits job?

Can you explain?

+4
source share
1 answer

[STAThread] - , , . , , , . , , , (aka loop) . -, , - , . - , , .

, WaitAll() , WaitOne() verboten.

WaitOne() , , . Thread.Join() - . , , CLR . CLR , , Application.Run(). Application.DoEvents(), , , .

. , , , . , . CLR , . , , SSCLI, CoreCLR, , - .

WaitAll() , . , .

. WaitOne(), BackgroundWorker.RunWorkerCompleted , TaskScheduler.FromCurrentSynchronizationContext() async.

+3

Source: https://habr.com/ru/post/1689674/


All Articles