title: Use windows froms with gtk
body: <p>Can I use OpenFileDialog in gtk# app for windows?
  When I use this sample code in my app it's freeze and crash.
  I also use Threading. It's worker with OpenFileDialog code.</p>
  
  <pre><code>using System;
  using Gtk;
  using System.Threading;
  namespace Test
  {
  public partial class basec : Gtk.Window
  {
      public basec() :
              base(Gtk.WindowType.Toplevel)
      {
          this.Build();
      }
      protected void OnDeleteEvent(object sender, DeleteEventArgs a)
      {
          Window win = new Window();
          win.Show();
          this.Destroy();
      }
      protected virtual void OnButtonAddPClicked(object sender, System.EventArgs e)
      {
          brows workerObject = new brows();
          Thread workerThread = new Thread(workerObject.DoWork);
          workerThread.Start();
          while (!workerThread.IsAlive);
          Thread.Sleep(1);
          workerObject.RequestStop();
          workerThread.Join();
      }
      protected virtual void OnButtonMenuClicked(object sender, System.EventArgs e)
      {
          Window win = new Window();
          win.Show();
          this.Destroy();
      }
      protected virtual void Exits(object sender, System.EventArgs e)
      {
          Window win = new Window();
          win.Show();
          this.Destroy();
      }
  }
  }
  </code></pre>
  
  <p>Worker:</p>
  
  <pre><code>using System;
  using System.IO;
  using System.Windows.Forms;
  namespace Test
  {
  public class brows
  {
      // This method will be called when the thread is started. 
      public void DoWork()
      {
          Stream myStream = null;
          OpenFileDialog openFileDialog1 = new OpenFileDialog();
  
          openFileDialog1.InitialDirectory = "c:\\";
          openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
          openFileDialog1.FilterIndex = 2;
          openFileDialog1.RestoreDirectory = true;
  
          if (openFileDialog1.ShowDialog() == DialogResult.OK)
          {
              try
              {
                  if ((myStream = openFileDialog1.OpenFile()) != null)
                  {
                      using (myStream)
                      {
                          // Insert code to read the stream here.
                      }
                  }
              }
              catch (Exception ex)
              {
                  MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
              }
          }
      }
      public void RequestStop()
      {
          _shouldStop = true;
      }
      private volatile bool _shouldStop;
  }
  }
  </code></pre>
  
  <p>Destroying windows is because my app use multiply window and it's my first gtk project.</p>