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
- TableLayoutSettingsTypeConverter.cs
- AttributeEmitter.cs
- HitTestWithPointDrawingContextWalker.cs
- Material.cs
- DataKey.cs
- SQLInt16Storage.cs
- DataGridRowEventArgs.cs
- IteratorAsyncResult.cs
- RawStylusInput.cs
- SplitterEvent.cs
- InstanceLockedException.cs
- TextRangeBase.cs
- TextElement.cs
- ModelItem.cs
- IdentifierService.cs
- Trace.cs
- MinMaxParagraphWidth.cs
- HttpCacheParams.cs
- CryptoKeySecurity.cs
- SharedStatics.cs
- BrushValueSerializer.cs
- AffineTransform3D.cs
- BitmapCodecInfo.cs
- ClientUriBehavior.cs
- EndpointDiscoveryMetadata11.cs
- CompositeTypefaceMetrics.cs
- MethodBody.cs
- AtomMaterializerLog.cs
- ScriptRegistrationManager.cs
- ReliableSession.cs
- ProxyManager.cs
- SqlDataSourceQueryEditor.cs
- CurrentChangingEventManager.cs
- XpsException.cs
- DataGridViewCellStateChangedEventArgs.cs
- FrameworkEventSource.cs
- ChangeNode.cs
- SqlFormatter.cs
- DomNameTable.cs
- SoapHeader.cs
- RemotingConfiguration.cs
- ThicknessKeyFrameCollection.cs
- EnumerableRowCollectionExtensions.cs
- NavigationPropertyEmitter.cs
- XmlCharType.cs
- EventDescriptorCollection.cs
- ToolStripItemImageRenderEventArgs.cs
- PrimaryKeyTypeConverter.cs
- PasswordDeriveBytes.cs
- SByteStorage.cs
- SortedDictionary.cs
- ToolboxComponentsCreatedEventArgs.cs
- SplitterPanel.cs
- ResourcesChangeInfo.cs
- ContentType.cs
- HttpResponseHeader.cs
- FlowPosition.cs
- EntityDataSourceView.cs
- DataColumnCollection.cs
- InputMethod.cs
- PropertyKey.cs
- SqlXml.cs
- CustomWebEventKey.cs
- HttpServerUtilityWrapper.cs
- __Filters.cs
- RadioButtonRenderer.cs
- InvokeCompletedEventArgs.cs
- Axis.cs
- EditorZoneAutoFormat.cs
- DictionaryContent.cs
- CompositeActivityTypeDescriptor.cs
- BamlWriter.cs
- DeviceContext.cs
- InternalSafeNativeMethods.cs
- ExecutionContext.cs
- OrderedDictionary.cs
- TemplateContent.cs
- Vector3DIndependentAnimationStorage.cs
- StateElementCollection.cs
- BaseTemplateBuildProvider.cs
- DiagnosticEventProvider.cs
- MultitargetUtil.cs
- DomainUpDown.cs
- XmlAnyAttributeAttribute.cs
- IArgumentProvider.cs
- AuthorizationSection.cs
- ResourceProviderFactory.cs
- ContainerUIElement3D.cs
- AttachedPropertyInfo.cs
- CheckBoxPopupAdapter.cs
- SchemaSetCompiler.cs
- DataSourceCache.cs
- UserNameServiceElement.cs
- DCSafeHandle.cs
- OdbcConnectionString.cs
- FixedBufferAttribute.cs
- XappLauncher.cs
- SQLConvert.cs
- XmlSchemaSequence.cs
- OptionalRstParameters.cs