Timer
from https://www.mono-project.com/docs/gui/gtksharp/responsive-applications/
from http://simplesandsamples.com/gui-timer.cs.html
Timeouts
You can use timeouts to invoke routines at specified intervals of time. This can be used to update status at specified times for example while a background thread runs or to notify the user of an action at a given interval.
Those of you who have done winforms development before will notice that GLib.Timeout is similar to System.Windows.Forms.Timer. The difference is that GLib.Timeouts are always invoked on the thread that owns the Gtk mainloop.
void StartClock ()
{
// Every second call `update_status' (1000 milliseconds)
GLib.Timeout.Add (1000, new GLib.TimeoutHandler (update_status));
}
bool update_status ()
{
time_label.Text = DateTime.Now.ToString ();
// returning true means that the timeout routine should be invoked
// again after the timeout period expires. Returning false would
// terminate the timeout.
return true;
}
from http://simplesandsamples.com/gui-timer.cs.html
(Forms)タイマーを使う
gui-timer.cs
|
|
$ mcs gui-timer.cs -r:System.Windows.Forms -r:System.Drawing
$ mono gui-timer.exe
$ mono gui-timer.exe
留言
張貼留言