public void ClientClose() { if (commandClient != null) { commandClient.DeviceOfflineEvent -= client_DeviceOfflineEvent; commandClient.DeviceOnlineEvent -= client_DeviceOnlineEvent; commandClient.ReceiveCommandResultEvent -= client_ReceiveCommandResultEvent; commandClient.LogOffEvent -= commandClient_LogOffEvent; if (status) { remoteCommand.DetachClient(commandClient); } } }