title: Design Pattern for multithreaded observers
body: <p>In a digital signal acquisition system, often data is pushed into an observer in the system by one thread.  </p>
  
  <p>example from <a href="http://en.wikipedia.org/wiki/Observer_pattern" rel="nofollow noreferrer">Wikipedia/Observer_pattern</a>:</p>
  
  <pre><code>foreach (IObserver observer in observers)
      observer.Update(message);
  </code></pre>
  
  <p>When e.g. a user action from e.g. a GUI-thread requires the data to stop flowing, you want to break the subject-observer connection, and even dispose of the observer alltogether.</p>
  
  <p>One may argue: you should just stop the data source, and wait for a sentinel value to dispose of the connection.  But that would incur more latency in the system.</p>
  
  <p>Of course, if the data pumping thread has just asked for the address of the observer, it might find it's sending a message to a destroyed object.</p>
  
  <p>Has someone created an 'official' Design Pattern countering this situation?  Shouldn't they?</p>