public void Dispose()
 {
     if (_isSubscribing)
     {
         if (_connectionWatcherThread != null)
         {
             _connectionWatcherThread.Abort();
             _connectionWatcherThread = null;
         }
         _processManagerServiceEventHandler.ProcessStatusesChanged -= _processManagerEventHandler.ProcessManagerServiceEventHandler_ProcessStatusesChanged;
         _processManagerServiceEventHandler.ConfigurationChanged   -= _processManagerEventHandler.ProcessManagerServiceEventHandler_ConfigurationChanged;
         _processManagerServiceEventHandler.DistributionCompleted  -= _processManagerEventHandler.ProcessManagerServiceEventHandler_DistributionCompleted;
     }
     if (_processManagerServiceClient != null)
     {
         try
         {
             _processManagerServiceClient.Unregister();
             _processManagerServiceClient.Abort();
         }
         catch {; }
         _processManagerServiceClient = null;
     }
     InitializationCompleted = null;
     ConnectionChanged       = null;
 }
        private void SetupClient()
        {
            NetTcpBinding binding = new NetTcpBinding()
            {
                MaxBufferSize          = Constants.MAX_MESSAGE_SIZE,
                MaxBufferPoolSize      = Constants.MAX_MESSAGE_SIZE * 2,
                MaxReceivedMessageSize = Constants.MAX_MESSAGE_SIZE,
                Security = { Mode = SecurityMode.None }
            };
            EndpointAddress endpointAddress = new EndpointAddress(new Uri($"net.tcp://{Machine.HostName}/ProcessManagerService"));
            InstanceContext context         = new InstanceContext(_processManagerServiceEventHandler);

            _processManagerServiceClient = new ProcessManagerServiceClient(context, binding, endpointAddress);
        }