TimerTaskStart Method
Factory method of TimerTasks.
A
TimerTask allows applications to execute a user-defined delegate in the context of a given
IContext thread.
The timer duration is subject to the timer resolution specified by the context property '
TimerResolutionInMsecs',
up to the nearest timer resolution interval.
For example, if the context timer resolution is 50 ms,
and a timer is started with a duration of 60 ms, then the timer duration is rounded up to 100 ms (2 ticks),
and then one further tick is added for a total timer duration of 150 ms. This extra tick accounts for the fact that the current tick might
be just about to advance when the timer is started. Thus, the actual timeout in this example is approximately in the range of 100 ms to 150 ms.
The timer callback delegate is invoked in the context of the context thread.
The timer durations are approximate; the actual duration can be affected by the
processing time spent in other callbacks by the context thread, such as for session or flowEvent events and received messages.
Note: disposing the corresponding context (IContext)
or any of its contained context timers (TimerTask), sessions (ISession)
or flows (IFlow)
must not be performed from within the registered userCallbackDelegate.
This timer service should only be used for applications that require a coarse timer service
(for example, a guard timer, or other timer uses that do not require a highly accurate timer service).
When a one-shot timer expires, the timer is automatically cancelled. When a repeat
timer expires, the timer is automatically rescheduled for the same duration, and
continues to run until stopped using
Dispose.
Note that the invoked timer callback delegate routine is allowed to start and stop timers.
Namespace: SolaceSystems.Solclient.MessagingAssembly: SolaceSystems.Solclient.Messaging (in SolaceSystems.Solclient.Messaging.dll) Version: 10.27.0
public static TimerTask Start(
IContext context,
TimerCallback userCallbackDelegate,
TimerMode timerMode,
long durationInMsecs,
Object userState
)
- context IContext
- The IContext to schedule the timer on
- userCallbackDelegate TimerCallback
- The user callback delegate to call when the timer expires. The call occurs over the IContext thread
- timerMode TimerMode
-
Use OneShot to create a one shot timer, Repeat otherwise
- durationInMsecs Int64
- The timer interval in milliseconds. This is subject to the specified timer resolution see Start(IContext, TimerCallback, TimerMode, Int64, Object) for more details
- userState Object
- An object reference that's passed to the userCallbackDelegate when the timer expires, can be null
TimerTaskReturns a TimerTask