-// \r
-// System.Web.Services.Protocols.WebClientAsyncResult.cs\r
-//\r
-// Author:\r
-// Tim Coleman (tim@timcoleman.com)\r
-// Lluis Sanchez Gual (lluis@ximian.com)\r
-//\r
-// Copyright (C) Tim Coleman, 2002\r
-//\r
+//
+// System.Web.Services.Protocols.WebClientAsyncResult.cs
+//
+// Author:
+// Tim Coleman (tim@timcoleman.com)
+// Lluis Sanchez Gual (lluis@ximian.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
//
// Permission is hereby granted, free of charge, to any person obtaining
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-\r
-using System.Net;\r
-using System.Threading;\r
-\r
-namespace System.Web.Services.Protocols {\r
- public class WebClientAsyncResult : IAsyncResult {\r
-\r
- #region Fields\r
-\r
- AsyncCallback _callback;\r
- object _asyncState;\r
-\r
- bool _completedSynchronously;\r
- bool _done;\r
- ManualResetEvent _waitHandle;\r
- \r
- internal object Result;\r
- internal Exception Exception;\r
- internal WebRequest Request;\r
- \r
- #endregion // Fields\r
-\r
- #region Constructors \r
-\r
- internal WebClientAsyncResult (WebRequest request, AsyncCallback callback, object asyncState)\r
- {\r
- _callback = callback; \r
- Request = request;\r
- _asyncState = asyncState;\r
- }\r
-\r
- #endregion // Constructors\r
-\r
- #region Properties\r
-\r
- public object AsyncState {\r
- get { return _asyncState; }\r
- }\r
-\r
- public WaitHandle AsyncWaitHandle \r
- {\r
- get\r
- {\r
- lock (this) {\r
- if (_waitHandle != null) return _waitHandle;\r
- _waitHandle = new ManualResetEvent (_done);\r
- return _waitHandle;\r
- }\r
- }\r
- }\r
-\r
- public bool CompletedSynchronously \r
- {\r
- get { return _completedSynchronously; }\r
- }\r
-\r
- public bool IsCompleted \r
- {\r
- get { lock (this) { return _done; } }\r
- }\r
-\r
- #endregion // Properties\r
-\r
- #region Methods\r
-\r
- public void Abort ()\r
- {\r
- Request.Abort ();\r
- }\r
-\r
- internal void SetCompleted (object result, Exception exception, bool async)\r
- {\r
- lock (this)\r
- {\r
- Exception = exception;\r
- Result = result;\r
- _done = true;\r
- _completedSynchronously = async;\r
- if (_waitHandle != null) _waitHandle.Set ();\r
- Monitor.PulseAll (this);\r
- }\r
- if (_callback != null) _callback (this);\r
- }\r
-\r
- internal void WaitForComplete ()\r
- {\r
- lock (this)\r
- {\r
- Monitor.Wait (this);\r
- }\r
- }\r
-\r
- #endregion // Methods\r
- }\r
+
+using System.Net;
+using System.Threading;
+
+namespace System.Web.Services.Protocols {
+ public class WebClientAsyncResult : IAsyncResult {
+
+ #region Fields
+
+ AsyncCallback _callback;
+ object _asyncState;
+
+ bool _completedSynchronously;
+ bool _done;
+ ManualResetEvent _waitHandle;
+
+ internal object Result;
+ internal Exception Exception;
+ internal WebRequest Request;
+
+ #endregion // Fields
+
+ #region Constructors
+
+ internal WebClientAsyncResult (WebRequest request, AsyncCallback callback, object asyncState)
+ {
+ _callback = callback;
+ Request = request;
+ _asyncState = asyncState;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public object AsyncState {
+ get { return _asyncState; }
+ }
+
+ public WaitHandle AsyncWaitHandle
+ {
+ get
+ {
+ lock (this) {
+ if (_waitHandle != null) return _waitHandle;
+ _waitHandle = new ManualResetEvent (_done);
+ return _waitHandle;
+ }
+ }
+ }
+
+ public bool CompletedSynchronously
+ {
+ get { return _completedSynchronously; }
+ }
+
+ public bool IsCompleted
+ {
+ get { lock (this) { return _done; } }
+ }
+
+ #endregion // Properties
+
+ #region Methods
+
+ public void Abort ()
+ {
+ Request.Abort ();
+ }
+
+ internal void SetCompleted (object result, Exception exception, bool async)
+ {
+ lock (this)
+ {
+ Exception = exception;
+ Result = result;
+ _done = true;
+ _completedSynchronously = async;
+ if (_waitHandle != null) _waitHandle.Set ();
+ Monitor.PulseAll (this);
+ }
+ if (_callback != null) _callback (this);
+ }
+
+ internal void WaitForComplete ()
+ {
+ lock (this)
+ {
+ Monitor.Wait (this);
+ }
+ }
+
+ #endregion // Methods
+ }
}