/// <summary> /// Begins a connection asynchronously. /// </summary> /// <param name="state">Any user object that is desired to be passed back to the connection completed callback. This will be represented /// through the <see>ConnectCompletedResult.State</see> property.</param> /// <param name="callback">The method to call when the connection has completed.</param> public virtual void ConnectAsync(object state, ConnectCompletedCallback callback) { WaitCallback ts = delegate { bool ok = Connect(); ConnectCompletedResult result = new ConnectCompletedResult { State = state, Succeeded = ok }; callback(result); }; ThreadPool.QueueUserWorkItem(ts); }
/// <summary> /// Begins a connection asynchronously. /// </summary> /// <param name="state">Any user object that is desired to be passed back to the connection completed callback. This will be represented /// through the <see>ConnectCompletedResult.State</see> property.</param> /// <param name="callback">The method to call when the connection has completed.</param> public virtual void ConnectAsync(object state, ConnectCompletedCallback callback) { WaitCallback ts = delegate { bool ok = Connect(); ConnectCompletedResult result = new ConnectCompletedResult { State = state, Succeeded = ok }; callback(result); }; ThreadPool.QueueUserWorkItem(ts); }