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
14 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
16 // Permission is hereby granted, free of charge, to any person obtaining
17 // a copy of this software and associated documentation files (the
18 // "Software"), to deal in the Software without restriction, including
19 // without limitation the rights to use, copy, modify, merge, publish,
20 // distribute, sublicense, and/or sell copies of the Software, and to
21 // permit persons to whom the Software is furnished to do so, subject to
22 // the following conditions:
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 using System.Threading;
38 using System.Runtime.CompilerServices;
40 namespace System.Runtime.Remoting.Messaging {
42 public class AsyncResult : IAsyncResult, IMessageSink {
46 object async_delegate;
50 bool endinvoke_called;
51 object async_callback;
52 MonoMethodMessage call_message;
53 IMessageCtrl message_ctrl;
54 IMessage reply_message;
56 internal AsyncResult ()
60 public virtual object AsyncState
67 public virtual WaitHandle AsyncWaitHandle {
71 handle = new ManualResetEvent (completed);
78 public virtual bool CompletedSynchronously
81 return sync_completed;
85 public virtual bool IsCompleted
92 public bool EndInvokeCalled
95 return endinvoke_called;
98 endinvoke_called = value;
102 public virtual object AsyncDelegate
105 return async_delegate;
109 public IMessageSink NextSink {
115 public virtual IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
118 throw new NotSupportedException ();
121 public virtual IMessage GetReplyMessage()
123 return reply_message;
126 public virtual void SetMessageCtrl (IMessageCtrl mc)
131 internal void SetCompletedSynchronously (bool completed)
133 sync_completed = completed;
136 internal IMessage EndInvoke ()
139 return reply_message;
142 public virtual IMessage SyncProcessMessage (IMessage msg)
147 NativeEventCalls.SetEvent_internal (handle.Handle);
149 if (async_callback != null)
151 AsyncCallback ac = (AsyncCallback) async_callback;
158 internal MonoMethodMessage CallMessage
160 get { return call_message; }
161 set { call_message = value; }