public Task <Example.Service.Thrift.User> GetUser(System.Int32 userId, object asyncState = null)
            {
                var taskSource_ = new TaskCompletionSource <Example.Service.Thrift.User>(asyncState);

                //构建请求发送buffer
                int seqID_      = this.client_.NextRequestSeqID();
                var sendBuffer_ = ThriftMarshaller.Serialize(new TMessage("GetUser", TMessageType.Call, seqID_),
                                                             new Service1.GetUser_args()
                {
                    UserId = userId
                });

                //开始异步发送
                this.client_.Send("Example.Service.Thrift.Service1+Iface", "GetUser", seqID_, sendBuffer_, (ex_) =>
                {
                    //处理异常回调
                    taskSource_.SetException(ex_);
                },
                                  (payload_) =>
                {
                    if (payload_ == null || payload_.Length == 0)
                    {
                        taskSource_.SetException(new TApplicationException(
                                                     TApplicationException.ExceptionType.MissingResult, "GetUser failed: Did not receive any data."));
                        return;
                    }

                    TMessage recvMsg_;
                    TApplicationException exServer_ = null;
                    Service1.GetUser_result result_ = null;

                    var oproto_ = ThriftMarshaller.GetBinaryProtocol(payload_);
                    try
                    {
                        //read TMessage
                        recvMsg_ = oproto_.ReadMessageBegin();
                        //read server return exception
                        if (recvMsg_.Type == TMessageType.Exception)
                        {
                            exServer_ = TApplicationException.Read(oproto_);
                        }
                        else
                        {
                            //read result
                            result_ = new Service1.GetUser_result();
                            result_.Read(oproto_);
                        }
                    }
                    catch (System.Exception ex_)
                    {
                        oproto_.Transport.Close();
                        taskSource_.SetException(ex_);
                        return;
                    }
                    oproto_.Transport.Close();

                    if (exServer_ != null)
                    {
                        taskSource_.SetException(exServer_);
                    }
                    else
                    {
                        if (result_.__isset.success)
                        {
                            taskSource_.SetResult(result_.Success);
                            return;
                        }
                        if (result_.__isset.ex)
                        {
                            taskSource_.SetException(result_.Ex);
                            return;
                        }

                        taskSource_.SetException(new TApplicationException(
                                                     TApplicationException.ExceptionType.MissingResult, "GetUser failed: unknown result"));
                    }
                });

                return(taskSource_.Task);
            }
            public Task<Example.Service.Thrift.User> GetUser(System.Int32 userId, object asyncState = null)
            {
                var taskSource_ = new TaskCompletionSource<Example.Service.Thrift.User>(asyncState);

                //构建请求发送buffer
                int seqID_ = this.client_.NextRequestSeqID();
                var sendBuffer_ = ThriftMarshaller.Serialize(new TMessage("GetUser", TMessageType.Call, seqID_),
                    new Service1.GetUser_args()
                    {
                        UserId = userId
                    });

                //开始异步发送
                this.client_.Send("Example.Service.Thrift.Service1+Iface", "GetUser", seqID_, sendBuffer_, (ex_) =>
                {
                    //处理异常回调
                    taskSource_.SetException(ex_);
                },
                (payload_) =>
                {
                    if (payload_ == null || payload_.Length == 0)
                    {
                        taskSource_.SetException(new TApplicationException(
                            TApplicationException.ExceptionType.MissingResult, "GetUser failed: Did not receive any data."));
                        return;
                    }

                    TMessage recvMsg_;
                    TApplicationException exServer_ = null;
                    Service1.GetUser_result result_ = null;

                    var oproto_ = ThriftMarshaller.GetBinaryProtocol(payload_);
                    try
                    {
                        //read TMessage
                        recvMsg_ = oproto_.ReadMessageBegin();
                        //read server return exception
                        if (recvMsg_.Type == TMessageType.Exception)
                            exServer_ = TApplicationException.Read(oproto_);
                        else
                        {
                            //read result
                            result_ = new Service1.GetUser_result();
                            result_.Read(oproto_);
                        }
                    }
                    catch (System.Exception ex_)
                    {
                        oproto_.Transport.Close();
                        taskSource_.SetException(ex_);
                        return;
                    }
                    oproto_.Transport.Close();

                    if (exServer_ != null)
                        taskSource_.SetException(exServer_);
                    else
                    {
                        if (result_.__isset.success)
                        {
                            taskSource_.SetResult(result_.Success);
                            return;
                        }
						if (result_.__isset.ex) {
taskSource_.SetException(result_.Ex);
return;
}

                        taskSource_.SetException(new TApplicationException(
                            TApplicationException.ExceptionType.MissingResult, "GetUser failed: unknown result"));
                    }
                });

                return taskSource_.Task;
            }