﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>John Chapman commented on I knew there were reasons for those multi threading warning lists</title><description>I don't know that I agree with your warning sign here.  I think there are plenty of other areas of interest to discuss before talking about third party code and locks.
  
  
First, I'm guessing the issue is that the Execute.OnUIThread runs synchronously, meaning it does not return until the item has been executed on the UI thread?  I would guess that would be the first warning sign.  If that update could be queued up instead (ran asynchronously to the caller, this issue would have been averted).
  
  
I'm also a proponent of having certain classes run exclusively on the UI thread, (presenter/viewmodel/view), with the back end running on the whatever threads.  Whenever code is executed on the presenter/viewmodel/view it is the UI thread (you ensure that through the semantics of your communication between UI and service layer).  You then send your data in an immutable fashion to the UI thread such that the need for locking on the UI thread pretty much goes away.  The code that is executing is always accessed from a single thread, so all of it's objects are free to touch, and all objects passed to these classes would be immutable (messages really) meaning they too can be accessed without working about locking.
  
  
That all being said there are a number of lessons to be learned from this example when you abstract out the UI thread part.  This same issue can arise even without a UI.
  
  
Thanks for the story.
</description><link>http://ayende.com/4204/i-knew-there-were-reasons-for-those-multi-threading-warning-lists#comment4</link><guid>http://ayende.com/4204/i-knew-there-were-reasons-for-those-multi-threading-warning-lists#comment4</guid><pubDate>Sat, 19 Sep 2009 17:24:50 GMT</pubDate></item><item><title>Ayende Rahien commented on I knew there were reasons for those multi threading warning lists</title><description>Mike,
  
I am. This is a case where I am updating the UI, I had to do something there.
</description><link>http://ayende.com/4204/i-knew-there-were-reasons-for-those-multi-threading-warning-lists#comment3</link><guid>http://ayende.com/4204/i-knew-there-were-reasons-for-those-multi-threading-warning-lists#comment3</guid><pubDate>Sat, 19 Sep 2009 11:37:10 GMT</pubDate></item><item><title>Mike Rettig commented on I knew there were reasons for those multi threading warning lists</title><description>Oren,
  
  
Locking on shared state? I thought you were a proponent of message based concurrency.  This post demonstrates exactly why concurrency combined with shared state is so hard.
  
  
Looking forward to your next thread race or deadlock,
  
  
Mike Rettig
</description><link>http://ayende.com/4204/i-knew-there-were-reasons-for-those-multi-threading-warning-lists#comment2</link><guid>http://ayende.com/4204/i-knew-there-were-reasons-for-those-multi-threading-warning-lists#comment2</guid><pubDate>Sat, 19 Sep 2009 03:39:55 GMT</pubDate></item><item><title>tobi commented on I knew there were reasons for those multi threading warning lists</title><description>so the line between 3rd party code and own, but unrelated, code is very blurry. this was an interesting example for that.
</description><link>http://ayende.com/4204/i-knew-there-were-reasons-for-those-multi-threading-warning-lists#comment1</link><guid>http://ayende.com/4204/i-knew-there-were-reasons-for-those-multi-threading-warning-lists#comment1</guid><pubDate>Sat, 19 Sep 2009 01:02:19 GMT</pubDate></item></channel></rss>