title: Windows Forms GUI hangs when calling OpenFileDialog.ShowDialog()
body: <p>my project a three tier architecture project talking to a WCF service in the backend. When the backend is able to fetch data from the service, it notifies the business layer using publish-subscribe, which in return notifies the GUI layer.</p>
  
  <p>I have added an OpenFileDialog to my UI design using Visual Studios designer. A button event handler calls the ShowDialog message. However, once I click the button, the whole UI hangs.</p>
  
  <p>Having googled around a bit, I found out that using delegates is the preferred way to handle tasks like this. However, with nor without delegate the problem persists.</p>
  
  <p>Currently my code looks like this:</p>
  
  <pre><code>private void bOpen_Click(object sender, EventArgs e)
  {
      Func&lt;Image&gt; del = delegate
      {
          OpenFileDialog d = new OpenFileDialog();
          if (d.ShowDialog() == DialogResult.OK)
          {
              return Image.FromFile(d.FileName);
          }
  
          return null;
      };
  
      Invoke(del);
  }
  </code></pre>
  
  <p>I'm coming from the Java world, so I'm not really familiar with the intricacies of C# UI programming.</p>
  
  <p>Anything I'm missing here?</p>