/// <summary> /// method to close the server by commanding the handlers to close first /// </summary> public void CloseServer() { // invoke close all directories CommandRecieved Event CommandRecievedEventArgs args = new CommandRecievedEventArgs((int)CommandEnum.CloseCommand, null, "*"); CommandRecieved.Invoke(this, args); // wait for all handlers to close while ((CommandRecieved != null) && (CommandRecieved.GetInvocationList().Length > 0)) { System.Threading.Thread.Sleep(1000); } // update logger m_logging.Log("Server is Closed", MessageTypeEnum.INFO); }
/// <summary> /// closing all directory handlers /// </summary> private void CloseAllDirHandlers() { try { foreach (EventHandler <CommandRecievedEventArgs> handler in CommandRecieved.GetInvocationList()) { handler(this, new CommandRecievedEventArgs((int)CommandEnum.CloseAllCommand, null, null)); CommandRecieved -= handler; } } catch (Exception) { } }