Class Watcher
- Namespace
- Cuemon.Runtime
- Assembly
- Cuemon.Core.dll
Represents the base class from which all implementations of resource monitoring should derive.
public abstract class Watcher : Disposable, IWatcher, IDisposable
- Inheritance
-
ObjectWatcher
- Implements
-
IDisposable
- Derived
- Inherited Members
Constructors
Watcher(Action<WatcherOptions>)
Initializes a new instance of the Watcher class.
protected Watcher(Action<WatcherOptions> setup)
Parameters
setup
Action<WatcherOptions>The WatcherOptions which needs to be configured.
Properties
DueTime
Gets or sets the System.TimeSpan representing the amount of time to delay before the Watcher starts signaling.
protected TimeSpan DueTime { get; }
Property Value
- 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.
protected TimeSpan DueTimeOnChanged { get; }
Property Value
- TimeSpan
Period
Gets the time interval between periodic signaling.
protected TimeSpan Period { get; }
Property Value
- TimeSpan
A System.TimeSpan representing the time interval between periodic signaling.
UtcLastModified
Gets the time when the resource being monitored was last changed.
public DateTime UtcLastModified { get; }
Property Value
- 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.
public DateTime UtcLastSignaled { get; }
Property Value
- 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
ChangeSignaling(TimeSpan)
Changes the signaling timer of the Watcher.
public void ChangeSignaling(TimeSpan dueTime)
Parameters
dueTime
TimeSpanA 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.
public virtual void ChangeSignaling(TimeSpan dueTime, TimeSpan period)
Parameters
dueTime
TimeSpanA 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.
period
TimeSpanThe 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
.
HandleSignaling()
Handles the signaling of this Watcher.
protected virtual void HandleSignaling()
HandleSignalingAsync()
Handles the signaling of this Watcher.
protected abstract Task HandleSignalingAsync()
Returns
- Task
The task object representing the asynchronous operation.
OnChangedRaised()
Raises the Changed event.
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.
protected virtual void OnChangedRaised(WatcherEventArgs e)
Parameters
e
WatcherEventArgsThe WatcherEventArgs instance containing the event data.
OnDisposeManagedResources()
Called when this object is being disposed by either Dispose() or Dispose(Boolean) having disposing
set to true
and Disposed is false
.
protected override void OnDisposeManagedResources()
OnDisposeUnmanagedResources()
Called when this object is being disposed by either Dispose() or Dispose(Boolean) and Disposed is false
.
protected override void OnDisposeUnmanagedResources()
SetUtcLastModified(DateTime)
Marks the time when a resource being monitored was last changed.
protected void SetUtcLastModified(DateTime utcLastModified)
Parameters
utcLastModified
DateTimeThe time when a resource being monitored was last changed.
StartMonitoring()
Starts the timer that will monitor this Watcher implementation.
public void StartMonitoring()
Events
Changed
Occurs when a resource has changed.
public event EventHandler<WatcherEventArgs> Changed
Event Type
- EventHandler<WatcherEventArgs>