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
- SynchronizationContext.cs
- PersonalizationProviderHelper.cs
- LexicalChunk.cs
- GatewayIPAddressInformationCollection.cs
- wgx_commands.cs
- RegexBoyerMoore.cs
- NavigationEventArgs.cs
- BrowsableAttribute.cs
- SharedConnectionListener.cs
- EnvelopeVersion.cs
- ContainerAction.cs
- TreeIterators.cs
- HtmlTernaryTree.cs
- CachedBitmap.cs
- ToolStripSplitButton.cs
- TextElement.cs
- Emitter.cs
- RawTextInputReport.cs
- ServiceModelConfigurationSection.cs
- X509UI.cs
- CqlWriter.cs
- WebBrowsableAttribute.cs
- ProcessHostServerConfig.cs
- IdentityNotMappedException.cs
- DataListAutoFormat.cs
- GridViewColumnHeader.cs
- FlowDocumentPaginator.cs
- TextEvent.cs
- ActivityTypeCodeDomSerializer.cs
- ToolBarButton.cs
- IsolatedStoragePermission.cs
- DbMetaDataFactory.cs
- TemplateControlParser.cs
- ImpersonationContext.cs
- WeakRefEnumerator.cs
- SecurityManager.cs
- DocumentOrderQuery.cs
- WebServiceAttribute.cs
- SurrogateEncoder.cs
- TabPanel.cs
- CDSCollectionETWBCLProvider.cs
- HwndKeyboardInputProvider.cs
- WarningException.cs
- XmlSchemaDocumentation.cs
- SQLDateTimeStorage.cs
- CorrelationHandle.cs
- MediaElementAutomationPeer.cs
- UrlMappingsModule.cs
- CharAnimationUsingKeyFrames.cs
- AnnotationComponentManager.cs
- FileDialogCustomPlace.cs
- TriState.cs
- ExternalFile.cs
- CharKeyFrameCollection.cs
- SvcMapFileLoader.cs
- ChameleonKey.cs
- CTreeGenerator.cs
- OdbcConnectionPoolProviderInfo.cs
- SyndicationSerializer.cs
- ParagraphVisual.cs
- SystemUnicastIPAddressInformation.cs
- AccessorTable.cs
- PolicyAssertionCollection.cs
- EntityDataSourceStatementEditorForm.cs
- DBCommand.cs
- Matrix.cs
- SqlCacheDependencySection.cs
- RoleManagerModule.cs
- HierarchicalDataTemplate.cs
- EntityViewGenerationConstants.cs
- Certificate.cs
- LoginView.cs
- InheritanceAttribute.cs
- FontEmbeddingManager.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- PropertyEntry.cs
- MultipartIdentifier.cs
- Sql8ConformanceChecker.cs
- StreamAsIStream.cs
- PrintingPermission.cs
- DetailsViewInsertedEventArgs.cs
- QueryMatcher.cs
- StructuralComparisons.cs
- PropertyMetadata.cs
- TypedReference.cs
- ResourceReader.cs
- ISCIIEncoding.cs
- FormClosedEvent.cs
- ProjectionCamera.cs
- securitycriticaldataClass.cs
- ContainerParaClient.cs
- CachedPathData.cs
- RadialGradientBrush.cs
- WorkflowServiceHost.cs
- BinaryOperationBinder.cs
- EnvironmentPermission.cs
- TypeUsage.cs
- CalendarBlackoutDatesCollection.cs
- ReadOnlyObservableCollection.cs
- BCLDebug.cs