Class Watcher
An abstract class for establishing a watcher, that can monitor and signal changes of a resource by raising the Changed event.
Implements
Namespace: Cuemon.Runtime
Assembly: Cuemon.Runtime.dll
Syntax
public abstract class Watcher : IDisposable
Constructors
| Improve this DocWatcher()
Initializes a new instance of the Watcher class, where the signaling is initiated immediately and hereby followed by a periodic signaling every 2 minutes.
Declaration
protected Watcher()
Watcher(TimeSpan)
Initializes a new instance of the Watcher class, where the signaling is initiated immediately.
Declaration
protected Watcher(TimeSpan period)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | period | The time interval between periodic signaling. Specify negative one (-1) milliseconds to disable periodic signaling. |
Watcher(TimeSpan, TimeSpan)
Initializes a new instance of the Watcher class.
Declaration
protected Watcher(TimeSpan dueTime, TimeSpan period)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | dueTime | A System.TimeSpan representing the amount of time to delay before the Watcher starts signaling. Specify negative one (-1) milliseconds to prevent the signaling from starting. Specify zero (0) to start the signaling immediately. |
System.TimeSpan | period | The time interval between periodic signaling. Specify negative one (-1) milliseconds to disable periodic signaling. |
Watcher(TimeSpan, TimeSpan, TimeSpan)
Initializes a new instance of the Watcher class.
Declaration
protected Watcher(TimeSpan dueTime, TimeSpan period, TimeSpan dueTimeOnChanged)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | dueTime | A System.TimeSpan representing the amount of time to delay before the Watcher starts signaling. Specify negative one (-1) milliseconds to prevent the signaling from starting. Specify zero (0) to start the signaling immediately. |
System.TimeSpan | period | The time interval between periodic signaling. Specify negative one (-1) milliseconds to disable periodic signaling. |
System.TimeSpan | dueTimeOnChanged | The amount of time to postpone a Changed event. Specify zero (0) to disable postponing. |
Properties
| Improve this DocDueTime
Gets or sets the System.TimeSpan representing the amount of time to delay before the Watcher starts signaling.
Declaration
protected TimeSpan DueTime { get; }
Property Value
Type | Description |
---|---|
System.TimeSpan | A System.TimeSpan representing the amount of time to delay before the Watcher starts signaling. |
DueTimeOnChanged
Gets the amount of time to postpone a Changed event.
Declaration
protected TimeSpan DueTimeOnChanged { get; }
Property Value
Type | Description |
---|---|
System.TimeSpan |
Period
Gets the time interval between periodic signaling.
Declaration
protected TimeSpan Period { get; }
Property Value
Type | Description |
---|---|
System.TimeSpan | A System.TimeSpan representing the time interval between periodic signaling. |
UtcLastModified
Gets time when the resource being monitored was last changed.
Declaration
public DateTime UtcLastModified { get; }
Property Value
Type | Description |
---|---|
System.DateTime | The time when the resource being monitored was last changed. |
Remarks
This property is measured in Coordinated Universal Time (UTC) (also known as Greenwich Mean Time).
UtcLastSignaled
Gets the time when the last signaling occurred.
Declaration
public DateTime UtcLastSignaled { get; }
Property Value
Type | Description |
---|---|
System.DateTime | The time when the last signaling occurred. |
Remarks
This property is measured in Coordinated Universal Time (UTC) (also known as Greenwich Mean Time).
Methods
| Improve this DocChangeSignaling(TimeSpan)
Changes the signaling timer of the Watcher.
Declaration
public void ChangeSignaling(TimeSpan dueTime)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | dueTime | A System.TimeSpan representing the amount of time to delay before the Watcher starts signaling. Specify negative one (-1) milliseconds to prevent the signaling from starting. Specify zero (0) to start the signaling immediately. |
ChangeSignaling(TimeSpan, TimeSpan)
Changes the signaling timer of the Watcher.
Declaration
public virtual void ChangeSignaling(TimeSpan dueTime, TimeSpan period)
Parameters
Type | Name | Description |
---|---|---|
System.TimeSpan | dueTime | A System.TimeSpan representing the amount of time to delay before the Watcher starts signaling. Specify negative one (-1) milliseconds to prevent the signaling from starting. Specify zero (0) to start the signaling immediately. |
System.TimeSpan | period | The time interval between periodic signaling. Specify negative one (-1) milliseconds to disable periodic signaling. |
Remarks
If dueTime
is zero (0), the signaling is started immediately. If dueTime
is negative one (-1) milliseconds, the signaling is never started; and the underlying timer is disabled, but can be re-enabled by specifying a positive value for dueTime
.
If period
is zero (0) or negative one (-1) milliseconds, and dueTime
is positive, the signaling is done once; the periodic behavior of the underlying timer is disabled, but can be re-enabled by specifying a value greater than zero for period
.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(Boolean)
Releases unmanaged and - optionally - managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
|
HandleSignaling()
Handles the signaling of this Watcher.
Declaration
protected abstract void HandleSignaling()
OnChangedRaised()
Raises the Changed event.
Declaration
protected void OnChangedRaised()
Remarks
This method raises the Changed event with UtcLastModified and DueTimeOnChanged passed to a new instance of WatcherEventArgs.
OnChangedRaised(WatcherEventArgs)
Raises the Changed event.
Declaration
protected virtual void OnChangedRaised(WatcherEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
WatcherEventArgs | e | The WatcherEventArgs instance containing the event data. |
SetUtcLastModified(DateTime)
Marks the time when a resource being monitored was last changed.
Declaration
protected void SetUtcLastModified(DateTime utcLastModified)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | utcLastModified | The time when a resource being monitored was last changed. |
Events
| Improve this DocChanged
Occurs when a resource has changed.
Declaration
public event EventHandler<WatcherEventArgs> Changed
Event Type
Type | Description |
---|---|
System.EventHandler<WatcherEventArgs> |