2 // System.Web.Services.Protocols.WebClientAsyncResult.cs
\r
5 // Tim Coleman (tim@timcoleman.com)
\r
6 // Lluis Sanchez Gual (lluis@ximian.com)
\r
8 // Copyright (C) Tim Coleman, 2002
\r
12 using System.Threading;
\r
14 namespace System.Web.Services.Protocols {
\r
15 public class WebClientAsyncResult : IAsyncResult {
\r
19 AsyncCallback _callback;
\r
22 bool _completedSynchronously;
\r
24 ManualResetEvent _waitHandle;
\r
26 internal SoapClientMessage Message;
\r
27 internal SoapExtension[] Extensions;
\r
29 internal object Result;
\r
30 internal Exception Exception;
\r
31 internal WebRequest Request;
\r
33 #endregion // Fields
\r
35 #region Constructors
\r
37 internal WebClientAsyncResult (WebRequest request, AsyncCallback callback, object asyncState)
\r
39 _callback = callback;
\r
41 _asyncState = asyncState;
\r
44 #endregion // Constructors
\r
48 public object AsyncState {
\r
49 get { return _asyncState; }
\r
52 public WaitHandle AsyncWaitHandle
\r
57 if (_waitHandle != null) return _waitHandle;
\r
58 _waitHandle = new ManualResetEvent (_done);
\r
64 public bool CompletedSynchronously
\r
66 get { return _completedSynchronously; }
\r
69 public bool IsCompleted
\r
71 get { lock (this) { return _done; } }
\r
74 #endregion // Properties
\r
78 public void Abort ()
\r
83 internal void SetCompleted (object result, Exception exception, bool async)
\r
87 Exception = exception;
\r
90 _completedSynchronously = async;
\r
91 if (_waitHandle != null) _waitHandle.Set ();
\r
92 Monitor.PulseAll (this);
\r
94 if (_callback != null) _callback (this);
\r
97 internal void WaitForComplete ()
\r
101 Monitor.Wait (this);
\r
105 #endregion // Methods
\r