Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / ComIntegration / ComPlusSynchronizationContext.cs / 1 / ComPlusSynchronizationContext.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.ComIntegration { using System; using System.Runtime.InteropServices; using System.Threading; using System.Diagnostics; using System.ServiceModel.Diagnostics; class ComPlusSynchronizationContext : SynchronizationContext { IServiceActivity activity; bool postSynchronous; public ComPlusSynchronizationContext(IServiceActivity activity, bool postSynchronous) { this.activity = activity; this.postSynchronous = postSynchronous; } public override void Send(SendOrPostCallback d, Object state) { DiagnosticUtility.DebugAssert("Send should never be called"); } public override void Post(SendOrPostCallback d, Object state) { ComPlusActivityTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationEnteringActivity, SR.TraceCodeComIntegrationEnteringActivity); ServiceCall call = new ServiceCall(d, state); if (this.postSynchronous) { this.activity.SynchronousCall(call); } else { this.activity.AsynchronousCall(call); } ComPlusActivityTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationLeftActivity, SR.TraceCodeComIntegrationLeftActivity); } public void Dispose() { while (Marshal.ReleaseComObject(this.activity) > 0) ; } class ServiceCall : IServiceCall { SendOrPostCallback callback; Object state; public ServiceCall(SendOrPostCallback callback, Object state) { this.callback = callback; this.state = state; } 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 (DiagnosticUtility.IsFatal(e)) throw; DiagnosticUtility.InvokeFinalHandler(e); } finally { if (activity != null) { activity.Dispose(); activity = null; } } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridRowHeaderAutomationPeer.cs
- GenericFlowSwitchHelper.cs
- WSTrustDec2005.cs
- SerializationObjectManager.cs
- CreateUserErrorEventArgs.cs
- ActiveXHelper.cs
- InkCanvasSelection.cs
- ApplicationInfo.cs
- DesignTimeHTMLTextWriter.cs
- DesignerDataTable.cs
- DataSourceGeneratorException.cs
- ThreadInterruptedException.cs
- IApplicationTrustManager.cs
- SwitchAttribute.cs
- DataGridViewCellStyleChangedEventArgs.cs
- TCEAdapterGenerator.cs
- EventTrigger.cs
- XmlDataImplementation.cs
- AssemblyUtil.cs
- ChangeInterceptorAttribute.cs
- LoginName.cs
- ADConnectionHelper.cs
- EnumConverter.cs
- Transactions.cs
- MembershipUser.cs
- DataGridViewRowsRemovedEventArgs.cs
- Command.cs
- ClientScriptManager.cs
- DiagnosticsConfigurationHandler.cs
- PolyQuadraticBezierSegment.cs
- TypedTableBase.cs
- Grant.cs
- EntityTypeBase.cs
- Authorization.cs
- WindowsScroll.cs
- XmlText.cs
- HttpStreamFormatter.cs
- ReturnValue.cs
- SqlCacheDependencyDatabaseCollection.cs
- FixedSOMPageConstructor.cs
- HttpDebugHandler.cs
- RichTextBox.cs
- XmlImplementation.cs
- VerticalConnector.xaml.cs
- DesignerCapabilities.cs
- BaseValidatorDesigner.cs
- IgnoreFileBuildProvider.cs
- NetSectionGroup.cs
- DocumentViewerBase.cs
- AcceleratedTokenProviderState.cs
- latinshape.cs
- LinqDataSourceSelectEventArgs.cs
- RemoteWebConfigurationHostStream.cs
- AutoGeneratedField.cs
- AutoGeneratedField.cs
- StringFormat.cs
- AssociationTypeEmitter.cs
- FormViewInsertedEventArgs.cs
- DataPagerFieldCollection.cs
- SchemaAttDef.cs
- basevalidator.cs
- DefaultHttpHandler.cs
- ConfigurationStrings.cs
- Logging.cs
- StretchValidation.cs
- AssemblyCache.cs
- HtmlTableRow.cs
- DPCustomTypeDescriptor.cs
- RegistryPermission.cs
- DecimalConstantAttribute.cs
- LinqDataSourceContextData.cs
- PlainXmlDeserializer.cs
- PopupEventArgs.cs
- FigureParaClient.cs
- StrokeIntersection.cs
- SkinBuilder.cs
- OutputWindow.cs
- SpecularMaterial.cs
- TemplateField.cs
- StaticSiteMapProvider.cs
- DbProviderServices.cs
- ModulesEntry.cs
- SessionEndedEventArgs.cs
- QueryExpr.cs
- QilFactory.cs
- MemberHolder.cs
- RadialGradientBrush.cs
- RuntimeCompatibilityAttribute.cs
- DropSource.cs
- SqlComparer.cs
- EntityCommandCompilationException.cs
- Pair.cs
- MenuCommand.cs
- XmlSchemaAnnotated.cs
- TogglePatternIdentifiers.cs
- InternalEnumValidator.cs
- BaseTreeIterator.cs
- Italic.cs
- _FtpControlStream.cs
- DesignerVerbCollection.cs