private void Exit() { lock (SyncRoot) { Logging.Debug("Process " + this + " exiting"); _state = SIPState.Exiting; if (_exiting != null) { Logging.Debug("Firing SIP exiting event: " + this); _exiting(this, new EventArgs()); } ResourceManager.CleanupAndUnregisterSIP(this); SIPManager.UnregisterSIP(this); _state = SIPState.Exited; if (_exited != null) { Logging.Debug("Firing SIP exited event: " + this); _exited(this, new EventArgs()); } if (_parent != null) { _parent.ChildExited(this); } } }
internal void Start(bool makeChildOfCurrentSIP) { // TODO: Nothing here is synchronized!!! Need C# lock construct!!! if (_state != SIPState.NotStarted) { throw new NotSupportedException("SIP already started"); } SIPManager.RegisterSIP(this); // the init process has no parent if (!makeChildOfCurrentSIP) { CurrentSIP.AddChild(this); } // setup input/output/error if (Output == null) { Output = new ConsoleTextWriter(); } if (Error == null) { Error = new ConsoleTextWriter(); } ResourceManager.RegisterSIP(this); _startThread.Start(); _state = SIPState.Running; }