Categories: .Net, C#
Posted by
mheydt on
12/29/2007 4:57 PM |
Comments (0)
I can across a curious issue tonight when doing some multithreading in WPF. Upon the user pressing a button on the WPF form, I was starting a few threads to accomplish some tasks in parallel, and I wanted to wait for both of those tasks to complete first as I need output from both of them to finalize the process that pressing the button entails. As usual I spun up a few threads, created a ManualResetEvent for each thread, and called WaitHandle.WaitAll on those handles. Much to my surprise this through an exception stating that WaitAll cannot be used from an STA thread!
I found this curious. Technically I don't understand why you can not call this from an STA thread as why can't an STA thread through that method monitor several other threads through those handles? I don't know. Anyway, the solution was to spin up another thread as the result of presssing the button that would then start those other threads, and the WaitAll then works fine in that thread as it defaults to MTA.
BTW, this is all because WPF UI's must run in STA, and the event handler for a button press then runs in STA and for all I know you can't change that.
d5a7f7d3-beaf-4f05-b964-25a93b6f2abe|0|.0
I got around to going back to my silverlight photo viewer project today, and was surprised to find that since upgrading to vs.net 2008 that the tools alpha for silverlight was not compatible. Fortunately, with a little googling I found this upgrade. Same name as the old tools, but a new publish date. It did appear that an uninstall of the non-working tools is needed first.
The error from VS.NET was:
“Package Load Failure
Package ‘Microsoft.VisualStudio.Silverlight.SLPackage, Microsoft.VisualStudio.Silverlight, Version=9.0.0.0,…”
And the link is:
http://www.microsoft.com/downloads/details.aspx?FamilyId=25144C27-6514-4AD4-8BCB-E2E051416E03&displaylang=en
6ced6b73-bf81-4c98-8118-2132c5d74b63|0|.0