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
- HtmlEmptyTagControlBuilder.cs
- DataReceivedEventArgs.cs
- Double.cs
- DBCommandBuilder.cs
- BamlResourceSerializer.cs
- UInt64Converter.cs
- FixedFindEngine.cs
- WebPart.cs
- XmlDataSourceNodeDescriptor.cs
- ServiceModelExtensionCollectionElement.cs
- PageHandlerFactory.cs
- PrimitiveDataContract.cs
- TreeWalker.cs
- EntryPointNotFoundException.cs
- ChangeProcessor.cs
- Int64Storage.cs
- XmlCodeExporter.cs
- XpsColorContext.cs
- DataGridViewCellMouseEventArgs.cs
- CellRelation.cs
- DataGridItem.cs
- ReadOnlyCollection.cs
- CryptoApi.cs
- LabelDesigner.cs
- XmlAnyAttributeAttribute.cs
- AssemblyCache.cs
- ToolStripItemImageRenderEventArgs.cs
- XmlWrappingReader.cs
- MailMessageEventArgs.cs
- CannotUnloadAppDomainException.cs
- XXXInfos.cs
- RoutedEventHandlerInfo.cs
- SessionPageStatePersister.cs
- WebFaultClientMessageInspector.cs
- Semaphore.cs
- XPathNode.cs
- EntityTypeEmitter.cs
- FixedSOMGroup.cs
- DataGridViewRowCollection.cs
- CollectionBase.cs
- PartDesigner.cs
- SafeRegistryHandle.cs
- XamlReaderHelper.cs
- ClaimComparer.cs
- CompoundFileStreamReference.cs
- ObjectIDGenerator.cs
- TemplateInstanceAttribute.cs
- SpanIndex.cs
- PolygonHotSpot.cs
- DataGridViewCellMouseEventArgs.cs
- FamilyMapCollection.cs
- _SSPISessionCache.cs
- ColumnWidthChangedEvent.cs
- NumericUpDownAccelerationCollection.cs
- ApplicationHost.cs
- KeyedCollection.cs
- WaitForChangedResult.cs
- ApplyTemplatesAction.cs
- FunctionImportMapping.cs
- Int32EqualityComparer.cs
- ProjectionQueryOptionExpression.cs
- RSACryptoServiceProvider.cs
- MessageSecurityVersionConverter.cs
- WebServiceData.cs
- PowerEase.cs
- EventOpcode.cs
- _AutoWebProxyScriptWrapper.cs
- ScrollChrome.cs
- WeakReferenceKey.cs
- DiagnosticTraceRecords.cs
- ExpressionBuilder.cs
- DateTimeFormat.cs
- DataChangedEventManager.cs
- TextContainerHelper.cs
- ValueExpressions.cs
- TagMapCollection.cs
- NumericExpr.cs
- AuthenticationException.cs
- AttachmentService.cs
- WizardForm.cs
- JsonServiceDocumentSerializer.cs
- FragmentQuery.cs
- D3DImage.cs
- AbstractDataSvcMapFileLoader.cs
- TableItemPattern.cs
- TrackingLocation.cs
- LocalizationComments.cs
- DPCustomTypeDescriptor.cs
- BadImageFormatException.cs
- SqlDataSourceSelectingEventArgs.cs
- QueueProcessor.cs
- ContentTextAutomationPeer.cs
- CurrentChangingEventArgs.cs
- WebPartTransformerCollection.cs
- SourceElementsCollection.cs
- SHA512Managed.cs
- ObjectRef.cs
- Frame.cs
- RuntimeConfig.cs
- BoundingRectTracker.cs