Rethreading a single threaded app.

This was solely my biggest challenge this year.

Between BackGroundWorker, SynchronizationContext, Thread.Start(), Begin and EndInvoke. These things aren’t magic and can’t save you from a single threaded application that makes many lots of calls to background synchronous methods that update the UI thread.

No matter what I did , I kept getting the STA thread error until I traced the culprit that was secretly updating the view model that was never thought of to be called from another thread.

I had to reach out a little and tag one of my former co-workers.

Sergey Barskiy, his advice which is very solid led me to really want to upgrade my application to 4.5 which just isn’t doable right now.

His advice in a blog (If you have 4.5) this is a valid approach and suggested: http://dotnetspeak.com/2013/04/converting-callback-functions-to-task-pattern
(He is also the best real-world developer I know in or out of Microsoft).

Due to the lack thereof for using 4.5 I ended up following the rabbit hole into the Reactive Extensions.

Bart J.F. De Smet is brilliant.
http://channel9.msdn.com/Blogs/codefest/DC2010T0100-Keynote-Rx-curing-your-asynchronous-programming-blues

This is a great watch for all developers and seems to be a good fit for my current threading blues. Using the Push mechanism rather than Pull.

Finally to finish a video by one of my friends here in Atlanta:

JIm Wooley’s

http://channel9.msdn.com/Shows/geekSpeak/geekSpeak-Recording-The-Reactive-Framework-with-Jim-Wooley

 

 

Now for the fun:   Here is the best information I could find on threading and the ObserveOn SubscribeOn http://www.introtorx.com/uat/content/v1.0.10621.0/13_SchedulingAndThreading.html

Share on Facebook

Leave a Reply

Your email address will not be published.