title: Deadlock using Control.Invoke?
body: <p>I'm building an app using TPL in VS2010 Ultimate. The most of the times I run the app it becomes unresponsive when I Call DoRepresentation() from the UI's thread.</p>
  
  <pre><code>void DoRepresentation()
  {
    Parallel.ForEach(cgs, loopOptions, g =&gt;
    {
      UpdateRepresentation(g);
    });
  }
  
  void UpdateRepresentation(object g)
  {
    view.Invoke(new Action(() =&gt;
    {
      representation = new MyRepresentation(g);
    }));
  }
  </code></pre>
  
  <p>I don't know why the app is becoming unresponsive. Am I having a deadlock?</p>
  
  <p>Inside <em>MyRepresentation</em> I do some calls to OpenGL.</p>
  
  <p><em>view</em> is a Control inside Form1 (the main form).</p>
  
  <p>When the app become unresponsive I pause it from the VS IDE and here's the info I get</p>
  
  <p><strong>In the "Parallel Tasks" window I get the following:</strong></p>
  
  <pre><code>ID  Status       Message&lt;br&gt;
  1    ?Waiting   Task1 is waiting on object: "Task2"&lt;br&gt;
  2    ?Waiting   No waiting information available&lt;br&gt;
  </code></pre>
  
  <p><strong>In the "Call Stack" window I get the following:</strong></p>
  
  <pre><code>[In a Sleep, wait, or join]&lt;br&gt;
  [External Code]&lt;br&gt;
  Test.dll!Render.DoRepresentation()&lt;br&gt;
  App1.exe!Form1.Button1_Click&lt;br&gt;
  </code></pre>
  
  <p>Any help will be appreciated.</p>