title: MEF Recomposition - Does it preserve existing instances?
body: <p>Suppose I have a MEF composition like this:</p>
  
  <pre><code>public class Composition
  {
      [ImportMany(AllowRecomposition = true)]
      IEnumerable&lt;ILongRunningProcess&gt; Processes { get; set; }
  
      public static void Main(string[] args)
      {
           var composition = new Composition();
           using (var catalog = new DirectoryCatalog("."))
           {
               using (var container = new CompositionContainer(catalog)
               {
                   container.SatisfyImportsOnce(composition);
                   //Fire off long running processes in response to stimuli
               }
           }
      }
  }
  </code></pre>
  
  <p>According to the documentation I've seen, I "have to consider thread-safety when using Recomposition."[<a href="http://msdn.microsoft.com/en-us/magazine/ee291628.aspx" rel="nofollow noreferrer">MSDN</a>]  </p>
  
  <p>Obviously for the case where I removed a type, I need to make sure that my long-running process can be garbage-collected safely.  But for types that existed before the recomposition and still exist after the recomposition, will I get new instances back for the contents of <code>Processes</code> whenever recomposition occurs, or is MEF able to preserve existing instances of imports when a catalog is recomposed?</p>
  
  <p>Based on the above article's suggestion that for <code>ICollection&lt;T&gt;</code> MEF will use the <code>Clear()</code> and <code>Add(T)</code> methods, I'm not hopeful, but I'd like to know for certain before I go write the synchronization code.</p>
  
  <p><b>EDIT</b> I just realized I can't use <code>this</code> in a static method; I've updated the code accordingly :)</p>