Author: miguel
Date: 2005-09-02 18:39:34 -0400 (Fri, 02 Sep 2005)
New Revision: 49380
Added:
trunk/gtk-sharp/sample/Thread.cs
Log:
Add sample, not in default build
Added: trunk/gtk-sharp/sample/Thread.cs
===================================================================
--- trunk/gtk-sharp/sample/Thread.cs 2005-09-02 22:39:17 UTC (rev 49379)
+++ trunk/gtk-sharp/sample/Thread.cs 2005-09-02 22:39:34 UTC (rev 49380)
@@ -0,0 +1,59 @@
+//
+// Thread.cs - Using threads with Gtk#
+//
+// Author: Miguel de Icaza
+//
+// (c) 2005 Novell, Inc.
+
+namespace GtkSamples {
+
+ using Gtk;
+ using Gdk;
+ using System;
+ using System.Threading;
+
+ public class HelloThreads {
+ static Label msg;
+ static Button but;
+ static int count;
+ static Thread thr;
+
+ public static int Main (string[] args)
+ {
+ Application.Init ();
+ Gtk.Window win = new Gtk.Window ("Gtk# Hello World");
+ win.DeleteEvent += new DeleteEventHandler
(Window_Delete);
+ msg = new Label ("Click to quit");
+ but = new Button (msg);
+ but.Clicked += delegate { thr.Abort ();
Application.Quit (); };
+ win.Add (but);
+ win.ShowAll ();
+
+ thr = new Thread (ThreadMethod);
+ thr.Start ();
+
+ Application.Run ();
+
+ return 0;
+ }
+
+ static void ThreadMethod ()
+ {
+ Console.WriteLine ("Starting thread");
+ while (true){
+ count++;
+ Thread.Sleep (500);
+ Application.Invoke (delegate {
+ msg.Text = String.Format ("Click to
Quit ({0})", count);
+ });
+ }
+ }
+
+ static void Window_Delete (object obj, DeleteEventArgs args)
+ {
+ Application.Quit ();
+ args.RetVal = true;
+ }
+
+ }
+}
Property changes on: trunk/gtk-sharp/sample/Thread.cs
___________________________________________________________________
Name: svn:eol-style
+ native
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches