public void Invoke(ArgType args) { if (EventFired != null) { EventFired.Invoke(this, args); } }
private void OnElapsedTime(object source, ElapsedEventArgs e) { EventFired?.Invoke(source, new DictionaryEventArgs() { Values = new Dictionary <string, object>() { { "Time", System.DateTime.Now } } }); }
/// <summary> /// Event invocator for the <see cref="EventFired"/> event /// </summary> /// <param name="triggerTime">The event's time in UTC</param> protected void OnEventFired(DateTime triggerTime) { // don't fire the event if we're turned off if (!Enabled) { return; } _callback?.Invoke(Name, _orderedEventUtcTimes.Current); EventFired?.Invoke(Name, triggerTime); }
/// <summary> /// Event invocator for the <see cref="EventFired"/> event /// </summary> /// <param name="triggerTime">The event's time in UTC</param> protected void OnEventFired(DateTime triggerTime) { try { // don't fire the event if we're turned off if (!Enabled) { return; } _callback?.Invoke(Name, _orderedEventUtcTimes.Current); EventFired?.Invoke(Name, triggerTime); } catch (Exception ex) { Log.Error($"ScheduledEvent.Scan(): Exception was thrown in OnEventFired: {ex}"); // This scheduled event failed, so don't repeat the same event _needsMoveNext = true; throw new ScheduledEventException(Name, ex.Message, ex); } }
private void TrayAgent_SpeechActionFired(SpeechEventArgs e) { SynthesizerState state = speech.State; if (e.Actions == Actions.ABOUT || e.Actions == Actions.RESTORE || e.Actions == Actions.EXIT) { EventFired?.Invoke(e); return; } if (e.Actions == Actions.HOTKEY_FIRED) { string lang = ""; string newMD5 = ""; string textBeforeCopy = Clipboard.GetText(TextDataFormat.Text); Util.Delay(10); clipboardBackup.Backup(); Util.Delay(5); Util.PressKey(Keys.ControlKey, false); Util.Delay(5); Util.PressKey(Keys.C, false); Util.Delay(20); Util.PressKey(Keys.C, true); Util.Delay(5); Util.PressKey(Keys.ControlKey, true); Util.Delay(400); string text = Clipboard.GetText(TextDataFormat.Text); clipboardBackup.Restore(); if (string.IsNullOrEmpty(text) || textBeforeCopy.Equals(text)) { sound.Play(); if (state == SynthesizerState.Speaking) { SpeakPause(); return; } if (state == SynthesizerState.Paused) { SpeakResume(); return; } } Parallel.Invoke(() => { Debug.WriteLine("Begin GetMd5Hash task..."); newMD5 = Util.GetMd5Hash(text); Debug.WriteLine("End GetMd5Hash task..."); }, () => { Debug.WriteLine("Begin languageDetection task..."); lang = languageDetection.Detect(text); Debug.WriteLine("End languageDetection task..."); }, () => { Debug.WriteLine("Begin Beep task..."); sound.Play(); Debug.WriteLine("End Beep task..."); } ); //if the text is the same if (newMD5.Equals(md5)) { if (speech.State == SynthesizerState.Ready) { md5 = ""; } if (state == SynthesizerState.Speaking) { SpeakPause(); } if (state == SynthesizerState.Paused) { SpeakResume(); } } //if the text has changed if (!newMD5.Equals(md5)) { SpeakStop(); SpeakStart(text, lang); md5 = newMD5; } } }
/// <summary> /// Normally a <pre>video</pre> element doesn't have a <pre>change</pre> event. /// We force one and a use it as a proxy for all the Media Events. /// </summary> /// <param name="args">The event args - Value contains our JSON</param> protected virtual void OnChange(ChangeEventArgs args) { var ThisEvent = args?.Value?.ToString(); VideoEventData videoData = new VideoEventData(); try { videoData = JsonSerializer.Deserialize <VideoEventData>(ThisEvent, serializationOptions); } catch (Exception ex) { LoggerFactory .CreateLogger(nameof(VideoExComponentBase)) .LogError(ex, "Failed to convert the JSON: {0}", ThisEvent); } switch (videoData.EventName) { case VideoEvents.Abort: Abort?.Invoke(videoData.State); AbortEvent.InvokeAsync(videoData.State); break; case VideoEvents.CanPlay: CanPlay?.Invoke(videoData.State); CanPlayEvent.InvokeAsync(videoData.State); break; case VideoEvents.CanPlayThrough: CanPlayThrough?.Invoke(videoData.State); CanPlayThroughEvent.InvokeAsync(videoData.State); break; case VideoEvents.DurationChange: DurationChange?.Invoke(videoData.State); DurationChangeEvent.InvokeAsync(videoData.State); break; case VideoEvents.Emptied: Emptied?.Invoke(videoData.State); EmptiedEvent.InvokeAsync(videoData.State); break; case VideoEvents.Ended: Ended?.Invoke(videoData.State); EndedEvent.InvokeAsync(videoData.State); break; case VideoEvents.Error: Error?.Invoke(videoData.State); ErrorEvent.InvokeAsync(videoData.State); break; case VideoEvents.LoadedData: LoadedData?.Invoke(videoData.State); LoadedDataEvent.InvokeAsync(videoData.State); break; case VideoEvents.LoadedMetadata: LoadedMetadata?.Invoke(videoData.State); LoadedMetadataEvent.InvokeAsync(videoData.State); break; case VideoEvents.LoadStart: LoadStart?.Invoke(videoData.State); LoadStartEvent.InvokeAsync(videoData.State); break; case VideoEvents.Pause: Pause?.Invoke(videoData.State); PauseEvent.InvokeAsync(videoData.State); break; case VideoEvents.Play: Play?.Invoke(videoData.State); PlayEvent.InvokeAsync(videoData.State); break; case VideoEvents.Playing: Playing?.Invoke(videoData.State); PlayingEvent.InvokeAsync(videoData.State); break; case VideoEvents.Progress: Progress?.Invoke(videoData.State); ProgressEvent.InvokeAsync(videoData.State); break; case VideoEvents.RateChange: RateChange?.Invoke(videoData.State); RateChangeEvent.InvokeAsync(videoData.State); break; case VideoEvents.Seeked: Seeking?.Invoke(videoData.State); SeekingEvent.InvokeAsync(videoData.State); break; case VideoEvents.Seeking: Seeking?.Invoke(videoData.State); SeekingEvent.InvokeAsync(videoData.State); break; case VideoEvents.Stalled: Stalled?.Invoke(videoData.State); StalledEvent.InvokeAsync(videoData.State); break; case VideoEvents.Suspend: Suspend?.Invoke(videoData.State); SuspendEvent.InvokeAsync(videoData.State); break; case VideoEvents.TimeUpdate: TimeUpdate?.Invoke(videoData.State); TimeUpdateEvent.InvokeAsync(videoData.State); break; case VideoEvents.VolumeChange: VolumeChange?.Invoke(videoData.State); VolumeChangeEvent.InvokeAsync(videoData.State); break; case VideoEvents.Waiting: Waiting?.Invoke(videoData.State); WaitingEvent.InvokeAsync(videoData.State); break; default: break; } // Here is our catch-all event handler call! EventFired?.Invoke(videoData); }
internal void Notify(NetworkEvent netEvent) { EventFired?.Invoke(netEvent); }