public void Stop(IEventProducer eventProducer) { this.PublishStateChange(eventProducer, "Stopping"); try { if (this.IServiceComponent != null) this.IServiceComponent.Stop(); this.PublishStateChange(eventProducer, "Stopped"); } catch (Exception ex) { this.PublishStateChangeFailed(eventProducer, "StopFailed", ex); throw; } finally { try { this.IServiceComponent.Dispose(); } catch { /* eating the exception */ } this.IServiceComponent = null; } }
public void Start(IEventProducer eventProducer) { if (!this.ServiceComponentData.IsActive) return; this.Activate(eventProducer); this.PublishStateChange(eventProducer, "Starting"); try { if (this.IServiceComponent == null) this.IServiceComponent = this.WorkerDomain.CreateInstanceAndUnwrap(this.ServiceComponentData.Assembly, this.ServiceComponentData.Class) as IWindowsServiceComponent; this.IServiceComponent.ConfigURL = this.ConfigURL; this.IServiceComponent.Configuration = this.ServiceComponentData.Config; this.IServiceComponent.Environment = this.EnvironmentConfig; this.IServiceComponent.Start(); this.PublishStateChange(eventProducer, "Started"); } catch (Exception ex) { this.Deactivate(eventProducer); this.PublishStateChangeFailed(eventProducer, "StartFailed", ex); throw; } }