2 // System.Net.FtpAsyncResult.cs
5 // Carlos Alberto Cortez (calberto.cortez@gmail.com)
7 // (c) Copyright 2006 Novell, Inc. (http://www.novell.com)
12 using System.Threading;
17 class FtpAsyncResult : IAsyncResult
19 FtpWebResponse response;
20 ManualResetEvent waitHandle;
22 AsyncCallback callback;
27 object locker = new object ();
29 public FtpAsyncResult (AsyncCallback callback, object state)
31 this.callback = callback;
35 public object AsyncState {
41 public WaitHandle AsyncWaitHandle {
44 if (waitHandle == null)
45 waitHandle = new ManualResetEvent (false);
52 public bool CompletedSynchronously {
58 public bool IsCompleted {
66 internal bool GotException {
68 return exception != null;
72 internal Exception Exception {
78 internal FtpWebResponse Response {
87 internal Stream Stream {
92 set { stream = value; }
95 internal void WaitUntilComplete ()
100 AsyncWaitHandle.WaitOne ();
103 internal bool WaitUntilComplete (int timeout, bool exitContext)
108 return AsyncWaitHandle.WaitOne (timeout, exitContext);
111 internal void SetCompleted (bool synch, Exception exc, FtpWebResponse response)
114 this.exception = exc;
115 this.response = response;
118 if (waitHandle != null)
124 internal void SetCompleted (bool synch, FtpWebResponse response)
126 SetCompleted (synch, null, response);
129 internal void SetCompleted (bool synch, Exception exc)
131 SetCompleted (synch, exc, null);
134 internal void DoCallback ()
136 if (callback != null)
145 internal void Reset ()
154 if (waitHandle != null)