public void Kill(SessionDiedEventArgs ex)
 {
     if (_sessionActive)
     {
         _sessionActive = false;
         _worker.CancelAsync();
         _client.Close();
         SessionDied(this, ex);
     }
 }
        private void DoClientWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var sessionDiedEvent = new SessionDiedEventArgs(e.Error);

            Kill(sessionDiedEvent);
        }
        private void DoServerReceiveDone(object sender, RunWorkerCompletedEventArgs e)
        {
            var sessionDiedEvent = new SessionDiedEventArgs(e.Error);

            Kill(sessionDiedEvent);
        }