Timers storage for service infrastructure. This is a core component for each service infrastructure where you need to invoke any process after some time.
This plugin can be configured through Plugin.Configuration or Plugin.ConfigurationHttp plugin.
Description
: — Timer description (For search simplicity)Timer Name
: — Timer name that can be used from applicationInterval
: 00:01:00 — Timer intervalSleep Hours
: Empty — Temporary suspend interval (Turned off by default)
StartTimeSpan
: 00:00:00 — Start suspend intervalEndTimeSpan
: 23:59:59 — End suspend intervalStart Interval (sec)
: 00:00:01 — Startup interval after host is startedWork Days
: 127 — Days when timer is workingWork Hours
: Empty — Hours when timer is working (Turned off by default)
StartTimeSpan
: 00:00:00 — Start timeEndTimeSpan
: 23:59:59 — End timeSingle Instance
: False — Timer can be launched only in one instance. (IPC will be launched with the timer)Timer Type
: TimersTimer — Type of used native timer (Available timers: System.Timers.Timer, System.Threading.Timer, System.Windows.Forms.Timer)Default
— Default settings for new timers. If plugin will use timer with unknown Timer Name
then this settings will be used as a default values./// <summary>Reference to plugin description</summary> public IPluginDescription PluginInstance { get { return this._pluginTimer ?? (this._pluginTimer = this.Plugin.Host.Plugins["69c79417-c168-434a-a597-4e224237a527"]); } } /// <summary>Launch timer with specific name</summary> /// <param name="key">Unique timer index to identify specific instance of launched timer</param> /// <param name="timerName">Timer name that is used to set specific timer settings. If timer with that name is not found then Default timer settings will be used</param> /// <param name="callback">Callback that will be called when timer is triggered</param> /// <param name="state">Data that will be transferred to callback menthow when timer is triggered</param> public void RegisterTimer(String key, String timerName, EventHandler<EventArgs> callback, Object state) { IPluginDescription pluginTimer = this.PluginInstance; if(pluginTimer == null) throw new ArgumentNullException("Plugin ID=69c79417-c168-434a-a597-4e224237a527 not installed"); pluginTimer.Type.GetMember<IPluginMethodInfo>("RegisterTimer") .Invoke(key, timerName, callback, state); } /// <summary>Stop timer by sending unique index of started timer</summary> /// <param name="key">Unique timer index to identify specific instance of launched timer</param> /// <returns>Timer successfully unregistered</returns> public Boolean UnregisterTimer(String key) { IPluginDescription pluginTimer = this.PluginInstance; if(pluginTimer == null) throw new ArgumentNullException("Plugin ID=69c79417-c168-434a-a597-4e224237a527 not installed"); return (Boolean)pluginTimer.Type.GetMember<IPluginMethodInfo>("UnregisterTimer") .Invoke(key); } /// <summary>Invoke timer by unique timer index</summary> /// <param name="key">Unique timer index that need to be invoked</param> public void InvokeTimer(String key) { IPluginDescription pluginTimer = this.PluginInstance; if(pluginTimer == null) throw new ArgumentNullException("Plugin ID=69c79417-c168-434a-a597-4e224237a527 not installed"); pluginTimer.Type.GetMember<IPluginMethodInfo>("InvokeTimer") .Invoke(key); } /// <summary>Get all launched timer names</summary> /// <returns>Name of all created timers</returns> public String[] GetTimersName() { IPluginDescription pluginTimer = this.PluginInstance; if(pluginTimer == null) return null; return (String[])pluginTimer.Type.GetMember<IPluginMethodInfo>("GetTimersName") .Invoke(); } /// <summary>Search for timer by specified timer name</summary> /// <param name="timerName">Timer name that we trying to find in launched timers</param> /// <returns>Timer with this name exists and launched</returns> public Boolean IsTimerExists(String timerName) { IPluginDescription pluginTimer = this.PluginInstance; if(pluginTimer == null) return false; return (Boolean)pluginTimer.Type.GetMember<IPluginMethodInfo>("IsTimerExists") .Invoke(timerName); }