protected override void OnStop() { AudioMeterEvent.Stop(); AudioMeterEvent.Wait(); AudioMeterEvent.Dispose(); AudioMeterEvent = null; }
static AudioMeterEvent CreateAudioMeterEvent(Options options, Logger logger) { var audioMeterEvent = new AudioMeterEvent( options.AudioDeviceId, new SignalRatio { FieldDecibels = options.MinimumLevelDecibels }, options.MinimumDuration, options.Period, options.KeepaliveInterval, options.KeepaliveDuration, logger); if (options.Uri != null) { var httpClient = new HttpClient(options.PayloadContentType, options.HttpUsername, options.HttpPassword, logger); audioMeterEvent.Sounding += (object sender, System.EventArgs eventArgs) => { httpClient.SendHttpRequest(options.Uri, options.SoundingPayload, logger); }; audioMeterEvent.StoppedSounding += (object sender, System.EventArgs eventArgs) => { httpClient.SendHttpRequest(options.Uri, options.StoppedSoundingPayload, logger); }; } return(audioMeterEvent); }
protected override void OnStart(string[] args) { AudioMeterEvent = CreateAudioMeterEvent(Options, new EventLogLogger(EventLog)); AudioMeterEvent.Start(); }