public void OnCall() { ServiceModelActivity activity = null; try { Guid guidLogicalThreadID = Guid.Empty; if (DiagnosticUtility.ShouldUseActivity) { IComThreadingInfo comThreadingInfo; comThreadingInfo = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(ComPlusActivityTrace.IID_IComThreadingInfo); if (comThreadingInfo != null) { comThreadingInfo.GetCurrentLogicalThreadId(out guidLogicalThreadID); activity = ServiceModelActivity.CreateBoundedActivity(guidLogicalThreadID); } ServiceModelActivity.Start(activity, SR.GetString(SR.TransferringToComplus, guidLogicalThreadID.ToString()), ActivityType.TransferToComPlus); } ComPlusActivityTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationExecutingCall, SR.TraceCodeComIntegrationExecutingCall); this.callback(this.state); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } DiagnosticUtility.InvokeFinalHandler(e); } finally { if (activity != null) { activity.Dispose(); activity = null; } } }
public void OnCall() { ServiceModelActivity activity = null; try { Guid empty = Guid.Empty; if (DiagnosticUtility.ShouldUseActivity) { IComThreadingInfo info = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(ComPlusActivityTrace.IID_IComThreadingInfo); if (info != null) { info.GetCurrentLogicalThreadId(out empty); activity = ServiceModelActivity.CreateBoundedActivity(empty); } ServiceModelActivity.Start(activity, System.ServiceModel.SR.GetString("TransferringToComplus", new object[] { empty.ToString() }), ActivityType.TransferToComPlus); } ComPlusActivityTrace.Trace(TraceEventType.Verbose, 0x50016, "TraceCodeComIntegrationExecutingCall"); this.callback(this.state); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } DiagnosticUtility.InvokeFinalHandler(exception); } finally { if (activity != null) { activity.Dispose(); activity = null; } } }
bool EnqueueContext(IAsyncResult listenerContextResult) { EventTraceActivity eventTraceActivity = null; HttpListenerContext listenerContext; bool enqueued = false; if (FxTrace.Trace.IsEnd2EndActivityTracingEnabled) { eventTraceActivity = (EventTraceActivity)listenerContextResult.AsyncState; if (eventTraceActivity == null) { eventTraceActivity = EventTraceActivity.GetFromThreadOrCreate(true); } } using (LockHelper.TakeReaderLock(this.listenerRWLock)) { if (this.listener == null) { return(true); } listenerContext = this.listener.EndGetContext(listenerContextResult); } // Grab the activity from the context and set that as the surrounding activity. // If a message appears, we will transfer to the message's activity next using (DiagnosticUtility.ShouldUseActivity ? ServiceModelActivity.BoundOperation(this.Activity) : null) { ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ? ServiceModelActivity.CreateBoundedActivityWithTransferInOnly(listenerContext.Request.RequestTraceIdentifier) : null; try { if (activity != null) { StartReceiveBytesActivity(activity, listenerContext.Request.Url); } if (DiagnosticUtility.ShouldTraceInformation) { TraceUtility.TraceHttpConnectionInformation(listenerContext.Request.LocalEndPoint.ToString(), listenerContext.Request.RemoteEndPoint.ToString(), this); } base.TraceMessageReceived(eventTraceActivity, this.ListenUri); HttpChannelListener channelListener; if (base.TryLookupUri(listenerContext.Request.Url, listenerContext.Request.HttpMethod, this.HostNameComparisonMode, listenerContext.Request.IsWebSocketRequest, out channelListener)) { HttpRequestContext context = HttpRequestContext.CreateContext(channelListener, listenerContext, eventTraceActivity); IAsyncResult httpContextReceivedResult = channelListener.BeginHttpContextReceived(context, onMessageDequeued, onContextReceived, DiagnosticUtility.ShouldUseActivity ? (object)new ActivityHolder(activity, context) : (object)context); if (httpContextReceivedResult.CompletedSynchronously) { enqueued = EndHttpContextReceived(httpContextReceivedResult); } else { // The callback has been enqueued. enqueued = true; } } else { HandleMessageReceiveFailed(listenerContext); } } finally { if (DiagnosticUtility.ShouldUseActivity && activity != null) { if (!enqueued) { // Error during enqueuing activity.Dispose(); } } } } return(enqueued); }