Hello can we synchronize Glib.Idle Thread ?

For example here, if I press "Hello World" three times, I want to have a
result like this :

1 (first click)
2
3
(...)
49
1 (second click)
2
3
4
(...)
30
1 (third click)
2
3
(...)
100

If there is no solution for you, how do you make something like this ?

Thx


public class HelloWorld {
 public void hello (object obj, EventArgs args)
 {
    Console.WriteLine("Hello World");

    // How to stop the previous Thread here ?

    GLib.Idle.Add (new IdleHandler (OnIdleHello));
    OnIdleHello();
 }

 public void OnIdleHello (object obj, EventArgs args)
 {
    while (i <= 100)
    {
      Console.WriteLine(i);
      Thread.Sleep(3000);
    }
 }

 static void delete_event (object obj, DeleteEventArgs args)
 {
   Console.WriteLine ("delete event occurred\n");
   Application.Quit ();
 }

 public static void Main(string[] args)
 {
   Application.Init ();
   Window window = new Window ("helloworld");
   window.DeleteEvent += new DeleteEventHandler (delete_event);
   window.BorderWidth = 10;

   Button btn = new Button ("Hello World");

   btn.Clicked += new EventHandler (hello);

   window.Add (btn);

   window.ShowAll ();
   Application.Run ();
 }
}


--
~~~~~
| klessou |
~~~~~
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to