using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace Taobao.Top.Link.Endpoints { public class SendCallback { private EventWaitHandle _handle; private Exception _error; private IDictionary _return; /// get which endpoint to send /// public EndpointProxy Target { get; private set; } /// get error in sending /// public Exception Error { get { return this._error; } internal set { this._error = value; this._handle.Set(); } } /// get reply /// public IDictionary Return { get { return this._return; } internal set { this._return = value; this._handle.Set(); } } public SendCallback(EndpointProxy endpointProxy) { this.Target = endpointProxy; this._handle = new EventWaitHandle(false, EventResetMode.AutoReset); } /// wait until got return message /// /// timeout in milliseconds public void WaitReturn(int timeout) { if (timeout > 0) { if (!this._handle.WaitOne(timeout, false)) throw new LinkException(Text.E_EXECUTE_TIMEOUT); } else this._handle.WaitOne(); } } }