示例#1
0
        private void Disconnect()
        {
            var state = _client.State;

            if (state != CommunicationState.Closing && state != CommunicationState.Closed)
            {
                _client.Close();
            }

            _client = null;
        }
        static void Main(string[] args)
        {
            var callback = new InstanceContext(new ClientCallback());
            var client   = new DuplexServiceClient(callback);

            client.Open();
            client.Register();
            Console.WriteLine("Press a key to exit");
            Console.ReadKey();
            client.Close();
        }
        public async void Unsubscribe()
        {
            try
            {
                if (serverModel.State == CommunicationState.Opened)
                {
                    await serverModel.UnsubscribeAsync(clientID);

                    serverModel.Close();
                }
            }
            catch (Exception)
            {
                serverModel.Abort();
            }
        }
示例#4
0
 public void Dispose()
 {
     client.Close();
 }