示例#1
0
        public Task Connect(EndPoint endPoint)
        {
            var tcs = new TaskCompletionSource <bool>();

            _pipeline.OpenConnection(endPoint,
                                     ex =>
            {
                _state = ClientState.Connect;
                if (ex != null)
                {
                    tcs.SetException(ProcessException(ex));
                }
                else
                {
                    tcs.SetResult(true);
                }
            });
            return(tcs.Task);
        }