Ejemplo n.º 1
0
        /// <summary>
        /// Установить соединение с DeviceManager
        /// </summary>
        public static void Connect()
        {
            try
            {
                if (connectionState == ConnectionState.Disconnected || connectionState == ConnectionState.Default)
                {
                    NetTcpBinding binder = new NetTcpBinding();
                    proxy = new DuplexChannelFactory <IService>(context, binder, new EndpointAddress(uri));

                    devMan = proxy.CreateChannel();

                    IChannel channel = devMan as IChannel;

                    channel.Faulted += new EventHandler(channel_Faulted);

                    channel.Closed  += new EventHandler(channel_Closed);
                    channel.Closing += new EventHandler(channel_Closing);

                    channel.Opening += new EventHandler(channel_Opening);
                    channel.Opened  += new EventHandler(channel_Opened);

                    channel.BeginOpen(null, null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
        public OpenAsyncResult(IChannel innerChannel, TimeSpan timeout, AsyncCallback onOpenDone, AsyncCallback callback, object state, DependencyTelemetry telemetry)
            : base(onOpenDone, callback, state, telemetry)
        {
            this.InnerChannel = innerChannel;

            this.OriginalResult = innerChannel.BeginOpen(timeout, OnComplete, this);
            if (this.OriginalResult.CompletedSynchronously)
            {
                innerChannel.EndOpen(this.OriginalResult);
                this.CompleteSynchronously();
            }
        }
 public IAsyncResult BeginOpen(AsyncCallback callback, object state)
 => _innerChannel.BeginOpen(callback, state);
Ejemplo n.º 4
0
 protected override IAsyncResult OnBeginOpen(
     TimeSpan timeout, AsyncCallback callback, object state)
 {
     return(channel.BeginOpen(timeout, callback, state));
 }