public void CloseHandler(string handler) { IDirectoryHandler directoryHandlerToRemove = null; foreach (IDirectoryHandler directoryHandler in HandlersList) { if (string.Compare(directoryHandler.GetDirectoryPath(), handler, StringComparison.Ordinal) == 0) { directoryHandlerToRemove = directoryHandler; //CommandRecieved -= directoryHandlerToRemove.OnCommandRecieved; directoryHandlerToRemove.StopHandleDirectory(); } } HandlersList.Remove(directoryHandlerToRemove); }