[Gtk-sharp-list] Mutli-Threading problem (Possible Bug)

Luciano _ lnc19 at hotmail.com
Wed Jan 24 17:47:08 EST 2007


I'm having a problem with multi-threading Gtk Application.  I don't know if 
it is a bug or a mistake, so any help would be great.
The problem is: I Start a new Thread. This thread has a callback to get back 
to main thread, in this call back i use Gtk.Application.Invoke to Open new 
Gtk.Dialog to Confirm an operation from the second thread. This dialog is 
opened but the Run method (from Gtk.Dialog.Run) does wait until end, it 
keeps running, so the second thread keep going, and does not wait for the 
response. It is hard to explain :) so, i put this code which is the problem:


      public delegate bool ReturnToMain();
      public class MyGtkWindow: Gtk.Window
      {
         private System.Threading.Thread mythread = null;
         public MyGtkWindow()
         {
                // All the Constructors
         }

         protected void SomeButtonEvent(object sender, EventArgs args)
         {
                OtherClass oc = new OtherClass(myCallBack);
                this.mythread = new System.Threading.Thread(new 
ThreadStart(oc.StartThread));
                this.mythread.Start();
         }

          protected bool MyCallBack()
         {
             Gtk.Application.Invoke( delegate {
             Gtk.Dialog myDialog = ....;
             myDialog.Run() // This is not stopped here
             return true;
             });
          }
      }
      public class OtherClass
      {
            protected ReturnToMain CallBackMain = null;
            public OtherClass(ReturnToMain callback)
            {
              this.CallBackMain = callback;
             }
             public void StartThread()
             {
                for(int x = 0; x < 3;x++) {
                  Console.WriteLine(this.CallBackMain()); // This print true 
evertime, and not wait for Run (on the call back Dialog to end. I need this 
response one by one)
                 }
             }
      }

Thanks in advanced.
Luciano

_________________________________________________________________
Visita MSN Latino Noticias: Todo lo que pasa en el mundo y en tu paín, ¡en 
tu idioma! http://latino.msn.com/noticias/



More information about the Gtk-sharp-list mailing list