Class Event
  
  Represents an event manageable by IEventTimer
 
  
  
    Inheritance
    System.Object
    
    
    Event
      
   
  
    Implements
    
    System.IDisposable
    
    
    
    
   
  
    Inherited Members
    
    
    
    
    
    
    
    
    
    
    
    
    
      System.Object.Equals(System.Object)
    
    
      System.Object.Equals(System.Object, System.Object)
    
    
      System.Object.GetHashCode()
    
    
      System.Object.GetType()
    
    
      System.Object.MemberwiseClone()
    
    
      System.Object.ReferenceEquals(System.Object, System.Object)
    
    
      System.Object.ToString()
    
   
  
  Assembly: NFX.dll
  Syntax
  
    public class Event : ApplicationComponent, IApplicationComponent, IDisposable, INamed, IExternallyParameterized, IConfigurable, ILocalizedTimeProvider
   
  Constructors
  
  
  
  
  Event(IEventTimer, IConfigSectionNode)
  
  
  Declaration
  
    public Event(IEventTimer timer, IConfigSectionNode config)
   
  Parameters
  
  
  
  
  Event(IEventTimer, String, TimerEvent, Nullable<TimeSpan>, IConfigSectionNode, EventBodyAsyncModel, Boolean)
  
  
  Declaration
  
    public Event(IEventTimer timer, string name = null, TimerEvent body = null, TimeSpan? interval = default (TimeSpan? ), IConfigSectionNode config = null, EventBodyAsyncModel bodyAsyncModel = EventBodyAsyncModel.AsyncTask, bool enabled = true)
   
  Parameters
  
  Fields
  
  
  
  CONFIG_EVENT_SECTION
  
  
  Declaration
  
    public const string CONFIG_EVENT_SECTION = "event"
   
  Field Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.String | 
         | 
      
    
  
  
  
  CONFIG_HANDLER_SECTION
  
  
  Declaration
  
    public const string CONFIG_HANDLER_SECTION = "handler"
   
  Field Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.String | 
         | 
      
    
  
  
  
  EventHandler
  References event handler that handles events. If it is null then only delegate events are called
 
  
  Declaration
  
    public IEventHandler EventHandler
   
  Field Value
  
  
  
  m_Lock
  
  
  Declaration
  
    protected readonly object m_Lock
   
  Field Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Object | 
         | 
      
    
  
  Properties
  
  
  
  
  BodyAsyncModel
  Defines how event body should be invoked
 
  
  Declaration
  
    [Config]
[ExternalParameter(new string[]{"time"})]
public virtual EventBodyAsyncModel BodyAsyncModel { get; set; }
   
  Property Value
  
  
  
  
  CallCount
  Returns how many times this event was called
 
  
  Declaration
  
    public int CallCount { get; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Int32 | 
         | 
      
    
  
  
  
  
  Context
  Adds arbitrary context object to the event
 
  
  Declaration
  
    [Config]
[ExternalParameter(new string[]{"time"})]
public object Context { get; set; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Object | 
         | 
      
    
  
  
  
  
  Enabled
  Specifies whether this event will fire/participate in timer loop
 
  
  Declaration
  
    [Config]
[ExternalParameter(new string[]{"time"})]
public bool Enabled { get; set; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Boolean | 
         | 
      
    
  
  
  
  
  EndDate
  Specifies when this event will stop firing in the local event time
 
  
  Declaration
  
    [Config]
[ExternalParameter(new string[]{"time"})]
public DateTime? EndDate { get; set; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Nullable<System.DateTime> | 
         | 
      
    
  
  
  
  
  ExternalParameters
  Returns named parameters that can be used to control this component
 
  
  Declaration
  
    public IEnumerable<KeyValuePair<string, Type>> ExternalParameters { get; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.Type>> | 
         | 
      
    
  
  
  
  
  Interval
  Specifies how often event fires
 
  
  Declaration
  
    [Config]
[ExternalParameter(new string[]{"time"})]
public TimeSpan Interval { get; set; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.TimeSpan | 
         | 
      
    
  
  
  
  
  LastCall
  Returns when was this event called for the last time in the local event time
 
  
  Declaration
  
    public DateTime LastCall { get; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.DateTime | 
         | 
      
    
  
  
  
  
  LastError
  Returns the last exception thrown from event handler or nul if no error happened
 
  
  Declaration
  
    public Exception LastError { get; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Exception | 
         | 
      
    
  
  
  
  
  LocalizedTime
  Returns current time localized per TimeLocation
 
  
  Declaration
  
    public DateTime LocalizedTime { get; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.DateTime | 
         | 
      
    
  
  
  
  
  MaxCount
  Specifies how many times this event can be called. If less or equal than zero then no limit is set
 
  
  Declaration
  
    [Config]
[ExternalParameter(new string[]{"time"})]
public int MaxCount { get; set; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Int32 | 
         | 
      
    
  
  
  
  
  Name
  
  
  Declaration
  
    public string Name { get; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.String | 
         | 
      
    
  
  
  
  
  StartDate
  Specifies when this event will start firing in the local event time
 
  
  Declaration
  
    [Config]
[ExternalParameter(new string[]{"time"})]
public DateTime? StartDate { get; set; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Nullable<System.DateTime> | 
         | 
      
    
  
  
  
  
  Status
  
  
  Declaration
  
    public EventStatus Status { get; }
   
  Property Value
  
  
  
  
  TimeLocation
  Returns time location that this Event instance operates under.
 
  
  Declaration
  
    public TimeLocation TimeLocation { get; set; }
   
  Property Value
  
  
  
  
  Timer
  
  
  Declaration
  
    public IEventTimer Timer { get; }
   
  Property Value
  
  Methods
  
  
  
  
  AdjustDate(Nullable<DateTime>)
  Adjusts date time Localized time
 
  
  Declaration
  
    protected DateTime? AdjustDate(DateTime? date)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.Nullable<System.DateTime> | 
        date | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Nullable<System.DateTime> | 
         | 
      
    
  
  
  
  
  
  
  
  Declaration
  
    public virtual void Configure(IConfigSectionNode config)
   
  Parameters
  
  
  
  
  Destructor()
  
  
  Declaration
  
    protected override void Destructor()
   
  Overrides
  
  
  
  
  DoFire()
  
  
  Declaration
  
    protected virtual void DoFire()
   
  
  
  
  DoHandleError(Exception)
  
  
  Declaration
  
    protected virtual void DoHandleError(Exception error)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.Exception | 
        error | 
         | 
      
    
  
  
  
  
  DoVisit(DateTime)
  Override to perform extra status checks
 
  
  Declaration
  
    protected virtual bool DoVisit(DateTime localNow)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.DateTime | 
        localNow | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Boolean | 
         | 
      
    
  
  
  
  
  ExternalGetParameter(String, out Object, String[])
  Gets external parameter value returning true if parameter was found
 
  
  Declaration
  
    public bool ExternalGetParameter(string name, out object value, params string[] groups)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.String | 
        name | 
         | 
      
      
        | System.Object | 
        value | 
         | 
      
      
        | System.String[] | 
        groups | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Boolean | 
         | 
      
    
  
  
  
  
  ExternalParametersForGroups(String[])
  Returns named parameters that can be used to control this component
 
  
  Declaration
  
    public IEnumerable<KeyValuePair<string, Type>> ExternalParametersForGroups(params string[] groups)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.String[] | 
        groups | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.Type>> | 
         | 
      
    
  
  
  
  
  ExternalSetParameter(String, Object, String[])
  Sets external parameter value returning true if parameter was found and set
 
  
  Declaration
  
    public bool ExternalSetParameter(string name, object value, params string[] groups)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.String | 
        name | 
         | 
      
      
        | System.Object | 
        value | 
         | 
      
      
        | System.String[] | 
        groups | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Boolean | 
         | 
      
    
  
  
  
  
  Fire(Boolean)
  Calls event regardless of any constraints.
Invokes a handler right away if syncInvoke is true or BodyAsyncModel is Sync,
otherwise queues the task on a thread pool either as a regular or long-running task depending on BodyAsyncModel
 
  
  Declaration
  
    public void Fire(bool syncInvoke = false)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.Boolean | 
        syncInvoke | 
         | 
      
    
  
  
  
  
  LocalizedTimeToUniversalTime(DateTime)
  Converts localized time to UTC time as of TimeLocation property
 
  
  Declaration
  
    public DateTime LocalizedTimeToUniversalTime(DateTime local)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.DateTime | 
        local | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.DateTime | 
         | 
      
    
  
  
  
  
  ResetCallCount()
  Resets call count counter. If this event has expired it will eventually transition to Started state.
Keep in mind that it may expire again if EndDate is set and past due
 
  
  Declaration
  
    public void ResetCallCount()
   
  
  
  
  UniversalTimeToLocalizedTime(DateTime)
  Converts universal time to local time as of TimeLocation property
 
  
  Declaration
  
    public DateTime UniversalTimeToLocalizedTime(DateTime utc)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.DateTime | 
        utc | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.DateTime | 
         | 
      
    
  
  
  
  
  VisitAndCheck(DateTime)
  Invoked by timer, checks all conditions and fires/expires event depending on the status.
Returns true if event was fired, false otherwise
 
  
  Declaration
  
    protected bool VisitAndCheck(DateTime utcNow)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.DateTime | 
        utcNow | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Boolean | 
         | 
      
    
  
  Events
  
  
  
  Body
  Event body that gets called when the event is due. The body is always invoked ASYNCHRONOUSLY
unless Fire(syncronous=true) is called in which case it gets called on a thread that called Fire(true)
 
  
  Declaration
  
    public event TimerEvent Body
   
  Event Type
  
  
  
  DefinitionChange
  Invoked when one of timer event definition parameters changes.
Always called synchronously on the same thread that made a change.
Subscribers should not block for long
 
  
  Declaration
  
    public event TimerEventDefinitionChange DefinitionChange
   
  Event Type
  
  
  
  StatusChange
  Invoked when timer event status changes. Always called synchronously by the timer thread.
Subscribers should not block for long
 
  
  Declaration
  
    public event TimerEventStatusChange StatusChange
   
  Event Type
  
  Implements
  
  
      System.IDisposable
  
  
  
  
  
  Extension Methods