/// <summary> /// Starts the service. /// </summary> /// <exception cref="InvalidOperationException">When no channels have been added to the service</exception> /// <exception cref="InvalidOperationException">When the service has already been started.</exception> public virtual void Start() { if (ChannelsToMonitor == null) { throw new InvalidOperationException("You must atleast add 1 channel to service before starting it."); } if (_serviceTimer.Enabled) { throw new InvalidOperationException("The service has already been started."); } _serviceTimer.Start(); OnServiceStarted?.Invoke(this, new OnServiceStartedArgs()); }
public void Start() { try { var portString = VirtualAssistant.Instance.SettingsManager["Channel"]["Port-Number"].Value; int portNumber; if (!int.TryParse(portString, out portNumber)) { return; } var baseAddress = $"http://localhost:{portNumber}/"; Server = WebApp.Start <ServerConfiguration>(baseAddress); IsStarted = true; ServiceTimer.Start(); } catch (Exception exception) { VirtualAssistant.Instance.Logger.Error(exception); } }
private void DoWork(object sender, ElapsedEventArgs e) { try { log.Info("Start logic"); ServiceTimer.Interval = 60 * 60 * 1000; GoIPDynDnsClient.Program.MainLogic(log); } catch (Exception x) { log.Error("Exception" + e); } finally { if (null != ServiceTimer) { ServiceTimer.Start(); // re - enable the timer } } }
private void ServiceTimer_Elapsed(object sender, ElapsedEventArgs e) { ServiceTimer.Stop(); Executor.ExecuteAction(CoreServiceRepository.DataProcessingApiRequest); ServiceTimer.Start(); }