X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem.Runtime.Remoting.Messaging%2FAsyncResult.cs;h=ff43f8dc0d0301c6df76aaf30b3e6e175dcdb352;hb=f03a1b538bfb0d9be810688e8713731e122320b5;hp=21eed42f99a2436a0bb3838f2ce2a185d58b9828;hpb=587b9ab706bd158b030bbc5bcf3c4f15625b44bf;p=mono.git diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs index 21eed42f99a..ff43f8dc0d0 100644 --- a/mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs +++ b/mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs @@ -33,11 +33,13 @@ using System; using System.Threading; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace System.Runtime.Remoting.Messaging { [System.Runtime.InteropServices.ComVisible (true)] -public class AsyncResult : IAsyncResult, IMessageSink { +[StructLayout (LayoutKind.Sequential)] +public class AsyncResult : IAsyncResult, IMessageSink, IThreadPoolWorkItem { #pragma warning disable 169, 414, 649 object async_state; @@ -60,6 +62,7 @@ public class AsyncResult : IAsyncResult, IMessageSink { IMessageCtrl message_ctrl; #pragma warning restore IMessage reply_message; + WaitCallback orig_cb; internal AsyncResult () { @@ -67,10 +70,28 @@ public class AsyncResult : IAsyncResult, IMessageSink { internal AsyncResult (WaitCallback cb, object state, bool capture_context) { + orig_cb = cb; + if (capture_context) { + var stackMark = default (StackCrawlMark); + current = ExecutionContext.Capture ( + ref stackMark, + ExecutionContext.CaptureOptions.IgnoreSyncCtx | ExecutionContext.CaptureOptions.OptimizeDefaultCase); + cb = delegate { + ExecutionContext.Run(current, ccb, this, true); + }; + } + async_state = state; async_delegate = cb; - if (capture_context) - current = ExecutionContext.Capture (); + } + + static internal ContextCallback ccb = new ContextCallback(WaitCallback_Context); + + static private void WaitCallback_Context(Object state) + { + AsyncResult obj = (AsyncResult)state; + WaitCallback wc = obj.orig_cb as WaitCallback; + wc(obj.async_state); } public virtual object AsyncState @@ -183,5 +204,17 @@ public class AsyncResult : IAsyncResult, IMessageSink { get { return call_message; } set { call_message = value; } } + + void IThreadPoolWorkItem.ExecuteWorkItem() + { + Invoke (); + } + + void IThreadPoolWorkItem.MarkAborted(ThreadAbortException tae) + { + } + + [MethodImplAttribute(MethodImplOptions.InternalCall)] + internal extern object Invoke (); } }