[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp Timer.cs,1.2,1.3
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp Timer.cs,1.2,1.3 |
Date: |
Mon, 23 Jun 2003 01:14:44 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/Xsharp
In directory subversions:/tmp/cvs-serv31418/Xsharp
Modified Files:
Timer.cs
Log Message:
Implement Forms timers.
Index: Timer.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/Timer.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Timer.cs 21 Jun 2003 11:16:18 -0000 1.2
--- Timer.cs 23 Jun 2003 05:14:42 -0000 1.3
***************
*** 40,44 ****
// Internal state.
private Display dpy;
! private TimerCallback callback;
private Object state;
private DateTime nextDue;
--- 40,44 ----
// Internal state.
private Display dpy;
! private Delegate callback;
private Object state;
private DateTime nextDue;
***************
*** 215,218 ****
--- 215,284 ----
/// <summary>
+ /// <para>Create a new timer.</para>
+ /// </summary>
+ ///
+ /// <param name="dpy">
+ /// <para>The display to create the timer for, or <see langword="null"/>
+ /// to use the application's primary display.</para>
+ /// </param>
+ ///
+ /// <param name="callback">
+ /// <para>The delegate to invoke when the timer expires.</para>
+ /// </param>
+ ///
+ /// <param name="state">
+ /// <para>The state information to pass to the callback.</para>
+ /// </param>
+ ///
+ /// <param name="dueTime">
+ /// <para>The number of milliseconds until the timer expires
+ /// for the first time.</para>
+ /// </param>
+ ///
+ /// <param name="period">
+ /// <para>The number of milliseconds between timer expiries, or
+ /// -1 to only expire once at <paramref name="dueTime"/>.</para>
+ /// </param>
+ ///
+ /// <exception cref="T:System.ArgumentNullException">
+ /// <para>The <paramref name="callback"/> parameter is
+ /// <see langword="null"/>.</para>
+ /// </exception>
+ ///
+ /// <exception cref="T:System.ArgumentOutOfRangeException">
+ /// <para>The <paramref name="dueTime"/> parameter is
+ /// less than zero.</para>
+ /// </exception>
+ public Timer(Display dpy, EventHandler callback,
+ Object state, int dueTime, int period)
+ {
+ if(callback == null)
+ {
+ throw new
ArgumentNullException("callback");
+ }
+ if(dpy == null)
+ {
+ this.dpy = Application.Primary.Display;
+ }
+ else
+ {
+ this.dpy = dpy;
+ }
+ if(dueTime < 0)
+ {
+ throw new ArgumentOutOfRangeException
+ ("dueTime",
S._("X_NonNegative"));
+ }
+ this.callback = callback;
+ this.state = state;
+ this.nextDue =
+ DateTime.Now + new TimeSpan
+ (dueTime *
TimeSpan.TicksPerMillisecond);
+ this.period = period;
+ this.stopped = false;
+ AddTimer();
+ }
+
+ /// <summary>
/// <para>Change the parameters for this timer.</para>
/// </summary>
***************
*** 272,275 ****
--- 338,342 ----
{
Stop();
+ state = null;
}
***************
*** 382,386 ****
// Invoke the timer's callback delegate.
activated = true;
! timer.callback(timer.state);
// Add the timer back onto the queue if
necessary.
--- 449,462 ----
// Invoke the timer's callback delegate.
activated = true;
! if(timer.callback is TimerCallback)
! {
! TimerCallback cb1 =
timer.callback as TimerCallback;
! cb1(timer.state);
! }
! else
! {
! EventHandler cb2 =
timer.callback as EventHandler;
! cb2(timer.state,
EventArgs.Empty);
! }
// Add the timer back onto the queue if
necessary.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/Xsharp Timer.cs,1.2,1.3,
Rhys Weatherley <address@hidden> <=