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;
19 class FtpAsyncResult : IAsyncResult
21 FtpWebResponse response;
22 ManualResetEvent waitHandle;
24 AsyncCallback callback;
29 object locker = new object ();
31 public FtpAsyncResult (AsyncCallback callback, object state)
33 this.callback = callback;
37 public object AsyncState {
43 public WaitHandle AsyncWaitHandle {
46 if (waitHandle == null)
47 waitHandle = new ManualResetEvent (false);
54 public bool CompletedSynchronously {
60 public bool IsCompleted {
68 internal bool GotException {
70 return exception != null;
74 internal Exception Exception {
80 internal FtpWebResponse Response {
89 internal Stream Stream {
94 set { stream = value; }
97 internal void WaitUntilComplete ()
102 AsyncWaitHandle.WaitOne ();
105 internal bool WaitUntilComplete (int timeout, bool exitContext)
110 return AsyncWaitHandle.WaitOne (timeout, exitContext);
113 internal void SetCompleted (bool synch, Exception exc, FtpWebResponse response)
116 this.exception = exc;
117 this.response = response;
120 if (waitHandle != null)
126 internal void SetCompleted (bool synch, FtpWebResponse response)
128 SetCompleted (synch, null, response);
131 internal void SetCompleted (bool synch, Exception exc)
133 SetCompleted (synch, exc, null);
136 internal void DoCallback ()
138 if (callback != null)
147 internal void Reset ()
156 if (waitHandle != null)