public void StartClone(DirectoryCloneConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException(nameof(configuration));
     }
     if (Status != ServiceHandlerStatus.Ready)
     {
         return;
     }
     lock (mainClientLockObject)
     {
         Status = ServiceHandlerStatus.Busy;
         var result =
             mainClient.SendAndRecieve(new byte[] {0}, configuration.ToBytes());
         if (result.Length > 1)
         {
             MessageBox.Show("Service error!");
             //Status = ServiceHandlerStatus.Error;
             //using (var exceptionStream = new MemoryStream(result))
             //{
             //    exceptionStream.Write(result, 0, result.Length);
             //    using (var leftoverStream = mainClient.ReceiveUntilEndStream())
             //    {
             //       exceptionStream.Write(leftoverStream.ToArray(),0,(int) leftoverStream.Length);
             //    }
             //    var formatter = new BinaryFormatter();
             //    var exception = formatter.Deserialize(exceptionStream) as Exception;
             //    if (exception != null)
             //        throw new ServiceException(exception,Ip);
             //}
         }
         Status = ServiceHandlerStatus.Complete;
     }
 }
 public void RetryConnect()
 {
     if (Connected)
     {
         return;
     }
     lock (mainClientLockObject)
     {
         if (mainClient == null)
         {
             Status = ServiceHandlerStatus.Unavailable;
             return;
         }
         mainClient.Reconnect();
         var serviceHandlerStatus = Connected
             ? ServiceHandlerStatus.Ready
             : ServiceHandlerStatus.Unavailable;
         if (serviceHandlerStatus != status)
             Status = serviceHandlerStatus;
     }
 }