Exemplo n.º 1
0
        void MultiplexPumpCompleted(IAsyncResult a)
        {
            try
            {
                try
                {
                    Pump.EndRunPump(a);
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Multiplex pump failed: {0}", ex.Message);
                }

                lock (connectLock)
                {
                    if (dataChannel != null && dataChannel.State == CommunicationState.Opened)
                    {
                        dataChannel.Disconnect();
                        dataChannel.Close();
                    }
                    dataChannel = null;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("Error closing data channel: {0}", ex.Message);
                lock (connectLock)
                {
                    if (dataChannel != null && dataChannel.State == CommunicationState.Opened)
                    {
                        dataChannel.Abort();
                    }
                    dataChannel = null;
                }
            }
            finally
            {
                foreach (MultiplexedTcpConnection connection in new List <MultiplexedTcpConnection>(connections.Values))
                {
                    try
                    {
                        connections.Remove(connection.Id);
                        connection.Dispose();
                    }
                    catch (Exception ex1)
                    {
                        Trace.TraceError("Error shutting down multiplex connection: {0}", ex1.Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void RunPump()
 {
     Pump.EndRunPump(this.BeginRunPump(null, null));
 }