2 // System.Runtime.Remoting.Messaging/AsyncResult.cs
5 // Joe Shaw (joe@ximian.com)
6 // Martin Baulig (martin@gnome.org)
7 // Dietmar Maurer (dietmar@ximian.com)
8 // Duncan Mak (duncan@ximian.com)
10 // (C) 2001 Ximian, Inc. http://www.ximian.com
11 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Threading;
35 using System.Runtime.CompilerServices;
37 namespace System.Runtime.Remoting.Messaging {
39 public class AsyncResult : IAsyncResult, IMessageSink {
43 object async_delegate;
47 bool endinvoke_called;
48 object async_callback;
49 ExecutionContext current;
50 ExecutionContext original;
52 // not part of MonoAsyncResult...
53 MonoMethodMessage call_message;
54 IMessageCtrl message_ctrl;
55 IMessage reply_message;
57 internal AsyncResult ()
61 public virtual object AsyncState
68 public virtual WaitHandle AsyncWaitHandle {
72 handle = new ManualResetEvent (completed);
79 public virtual bool CompletedSynchronously
82 return sync_completed;
86 public virtual bool IsCompleted
93 public bool EndInvokeCalled
96 return endinvoke_called;
99 endinvoke_called = value;
103 public virtual object AsyncDelegate
106 return async_delegate;
110 public IMessageSink NextSink {
116 public virtual IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
119 throw new NotSupportedException ();
122 public virtual IMessage GetReplyMessage()
124 return reply_message;
127 public virtual void SetMessageCtrl (IMessageCtrl mc)
132 internal void SetCompletedSynchronously (bool completed)
134 sync_completed = completed;
137 internal IMessage EndInvoke ()
140 return reply_message;
143 public virtual IMessage SyncProcessMessage (IMessage msg)
148 NativeEventCalls.SetEvent_internal (handle.Handle);
150 if (async_callback != null)
152 AsyncCallback ac = (AsyncCallback) async_callback;
159 internal MonoMethodMessage CallMessage
161 get { return call_message; }
162 set { call_message = value; }