internal static void NotifyProfiler(IMessage msg, RemotingProfilerEvent profilerEvent) { if (profilerEvent != RemotingProfilerEvent.ClientSend) { if (profilerEvent != RemotingProfilerEvent.ClientReceive || !RemotingServices.CORProfilerTrackRemoting()) { return; } Guid id = Guid.Empty; if (RemotingServices.CORProfilerTrackRemotingCookie()) { object obj = msg.Properties[(object)"CORProfilerCookie"]; if (obj != null) { id = (Guid)obj; } } RemotingServices.CORProfilerRemotingClientReceivingReply(id, false); } else { if (!RemotingServices.CORProfilerTrackRemoting()) { return; } Guid id; RemotingServices.CORProfilerRemotingClientSendingMessage(out id, false); if (!RemotingServices.CORProfilerTrackRemotingCookie()) { return; } msg.Properties[(object)"CORProfilerCookie"] = (object)id; } }
public virtual IMessageCtrl AsyncProcessMessage(IMessage reqMsg, IMessageSink replySink) { IMessage message = InternalSink.ValidateMessage(reqMsg); IMessageCtrl result = null; if (message == null) { message = InternalSink.DisallowAsyncActivation(reqMsg); } if (message != null) { if (replySink != null) { replySink.SyncProcessMessage(message); } } else { if (RemotingServices.CORProfilerTrackRemotingAsync()) { Guid guid; RemotingServices.CORProfilerRemotingClientSendingMessage(out guid, true); if (RemotingServices.CORProfilerTrackRemotingCookie()) { reqMsg.Properties["CORProfilerCookie"] = guid; } if (replySink != null) { IMessageSink messageSink = new ClientAsyncReplyTerminatorSink(replySink); replySink = messageSink; } } Context currentContext = Thread.CurrentContext; currentContext.NotifyDynamicSinks(reqMsg, true, true, true, true); if (replySink != null) { replySink = new AsyncReplySink(replySink, currentContext); } object[] array = new object[3]; InternalCrossContextDelegate internalCrossContextDelegate = new InternalCrossContextDelegate(ClientContextTerminatorSink.AsyncProcessMessageCallback); IMessageSink channelSink = this.GetChannelSink(reqMsg); array[0] = reqMsg; array[1] = replySink; array[2] = channelSink; if (channelSink != CrossContextChannel.MessageSink) { result = (IMessageCtrl)Thread.CurrentThread.InternalCrossContextCallback(Context.DefaultContext, internalCrossContextDelegate, array); } else { result = (IMessageCtrl)internalCrossContextDelegate(array); } } return(result); }
public virtual IMessageCtrl AsyncProcessMessage(IMessage reqMsg, IMessageSink replySink) { IMessage msg = InternalSink.ValidateMessage(reqMsg); IMessageCtrl ctrl = null; if (msg == null) { msg = InternalSink.DisallowAsyncActivation(reqMsg); } if (msg != null) { if (replySink != null) { replySink.SyncProcessMessage(msg); } return(ctrl); } if (RemotingServices.CORProfilerTrackRemotingAsync()) { Guid guid; RemotingServices.CORProfilerRemotingClientSendingMessage(out guid, true); if (RemotingServices.CORProfilerTrackRemotingCookie()) { reqMsg.Properties["CORProfilerCookie"] = guid; } if (replySink != null) { IMessageSink sink = new ClientAsyncReplyTerminatorSink(replySink); replySink = sink; } } Context currentContext = Thread.CurrentContext; currentContext.NotifyDynamicSinks(reqMsg, true, true, true, true); if (replySink != null) { replySink = new System.Runtime.Remoting.Messaging.AsyncReplySink(replySink, currentContext); } object[] args = new object[3]; InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(ClientContextTerminatorSink.AsyncProcessMessageCallback); IMessageSink channelSink = this.GetChannelSink(reqMsg); args[0] = reqMsg; args[1] = replySink; args[2] = channelSink; if (channelSink != CrossContextChannel.MessageSink) { return((IMessageCtrl)Thread.CurrentThread.InternalCrossContextCallback(Context.DefaultContext, ftnToCall, args)); } return((IMessageCtrl)ftnToCall(args)); }
// // INTERNAL PROFILER NOTIFICATION SERVICES // internal static void NotifyProfiler(IMessage msg, RemotingProfilerEvent profilerEvent) { switch (profilerEvent) { case RemotingProfilerEvent.ClientSend: { if (RemotingServices.CORProfilerTrackRemoting()) { Guid g; RemotingServices.CORProfilerRemotingClientSendingMessage(out g, false); if (RemotingServices.CORProfilerTrackRemotingCookie()) { msg.Properties["CORProfilerCookie"] = g; } } break; } // case RemotingProfilerEvent.ClientSend case RemotingProfilerEvent.ClientReceive: { if (RemotingServices.CORProfilerTrackRemoting()) { Guid g = Guid.Empty; if (RemotingServices.CORProfilerTrackRemotingCookie()) { Object obj = msg.Properties["CORProfilerCookie"]; if (obj != null) { g = (Guid)obj; } } RemotingServices.CORProfilerRemotingClientReceivingReply(g, false); } break; } // case RemotingProfilerEvent.ClientReceive } // switch (event) } // NotifyProfiler
internal static void NotifyProfiler(IMessage msg, RemotingProfilerEvent profilerEvent) { switch (profilerEvent) { case RemotingProfilerEvent.ClientSend: Guid guid; if (!RemotingServices.CORProfilerTrackRemoting()) { break; } RemotingServices.CORProfilerRemotingClientSendingMessage(out guid, false); if (!RemotingServices.CORProfilerTrackRemotingCookie()) { break; } msg.Properties["CORProfilerCookie"] = guid; return; case RemotingProfilerEvent.ClientReceive: if (RemotingServices.CORProfilerTrackRemoting()) { Guid empty = Guid.Empty; if (RemotingServices.CORProfilerTrackRemotingCookie()) { object obj2 = msg.Properties["CORProfilerCookie"]; if (obj2 != null) { empty = (Guid)obj2; } } RemotingServices.CORProfilerRemotingClientReceivingReply(empty, false); } break; default: return; } }
[System.Security.SecurityCritical] // auto-generated public virtual IMessageCtrl AsyncProcessMessage(IMessage reqMsg, IMessageSink replySink) { Message.DebugOut("+++++++++++++++++++++++++ CliCtxTerminator: AsyncProcessMsg"); IMessage errMsg = ValidateMessage(reqMsg); IMessageCtrl msgCtrl = null; if (errMsg == null) { errMsg = DisallowAsyncActivation(reqMsg); } if (errMsg != null) { if (replySink != null) { replySink.SyncProcessMessage(errMsg); } } else { // If active, notify the profiler that an asynchronous remoting call is being made. if (RemotingServices.CORProfilerTrackRemotingAsync()) { Guid g; RemotingServices.CORProfilerRemotingClientSendingMessage(out g, true); if (RemotingServices.CORProfilerTrackRemotingCookie()) { reqMsg.Properties["CORProfilerCookie"] = g; } // Only wrap the replySink if the call wants a reply if (replySink != null) { // Now wrap the reply sink in our own so that we can notify the profiler of // when the reply is received. Upon invocation, it will notify the profiler // then pass control on to the replySink passed in above. IMessageSink profSink = new ClientAsyncReplyTerminatorSink(replySink); // Replace the reply sink with our own replySink = profSink; } } Context cliCtx = Thread.CurrentContext; // Notify dynamic sinks that an Async call started cliCtx.NotifyDynamicSinks( reqMsg, true, // bCliSide true, // bStart true, // bAsync true); // bNotifyGlobals // Intercept the async reply to force the thread back // into the client-context before it executes further // and to notify dynamic sinks if (replySink != null) { replySink = new AsyncReplySink(replySink, cliCtx); } Object[] args = new Object[] { null, null, null }; InternalCrossContextDelegate xctxDel = new InternalCrossContextDelegate(AsyncProcessMessageCallback); IMessageSink channelSink = GetChannelSink(reqMsg); // Forward call to the channel. args[0] = reqMsg; args[1] = replySink; args[2] = channelSink; // Move to default context unless we are going through // the cross-context channel if (channelSink != CrossContextChannel.MessageSink) { msgCtrl = (IMessageCtrl)Thread.CurrentThread.InternalCrossContextCallback(Context.DefaultContext, xctxDel, args); } else { msgCtrl = (IMessageCtrl)xctxDel(args); } } return(msgCtrl); }