mcs26
asked on
C# Win Form STA Thread is not supported
Hi,
I had a class I used that use's multiple threads. I have since added this class to a new windows from project. The code complies however at the line below,
an NotSupportedException was unhandlewed is thrown. The error message is "WaitAll for multiple handles on a STA thread is not supported".
After reading some webpages on google, what I understand is that a window form run in single thread so cannot use multi threading without changing the attribute to MTA. Is this correct and how do I do such a thing? Also is this the same for WPF forms as I'm looking to learn about them very soon.
Thanks,
M
I had a class I used that use's multiple threads. I have since added this class to a new windows from project. The code complies however at the line below,
WaitHandle.WaitAll(doneEvents);
an NotSupportedException was unhandlewed is thrown. The error message is "WaitAll for multiple handles on a STA thread is not supported".
After reading some webpages on google, what I understand is that a window form run in single thread so cannot use multi threading without changing the attribute to MTA. Is this correct and how do I do such a thing? Also is this the same for WPF forms as I'm looking to learn about them very soon.
Thanks,
M
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi idle_mind,
Thanks for the reply. I think I have seen this as a viable soultion but wanted to know if I could change the attribute of either a windows form or WPF form to enable me to use to WaitHandle.WaitAll method.
Cheers
M
Thanks for the reply. I think I have seen this as a viable soultion but wanted to know if I could change the attribute of either a windows form or WPF form to enable me to use to WaitHandle.WaitAll method.
Cheers
M
ASKER
Thanks for the reply. Sorry those link's don't make a huge amount of sense to me. Am I able to change the attribute of a windows form & WPF to MTA from STA and make use of multithreading?
Cheers
M