Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / WasHosting / System / ServiceModel / WasHosting / BaseAppDomainProtocolHandler.cs / 1305376 / BaseAppDomainProtocolHandler.cs
//---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel.WasHosting { using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.ServiceModel; using System.ServiceModel.Channels; using System.Web; using System.Web.Hosting; using System.ServiceModel.Activation; using System.ServiceModel.Diagnostics; using System.Runtime; using System.Runtime.InteropServices; abstract class BaseAppDomainProtocolHandler : AppDomainProtocolHandler { public readonly static TimeSpan DefaultStopTimeout = TimeSpan.FromSeconds(30); string protocolId; IListenerChannelCallback listenerChannelCallback; protected ListenerChannelContext listenerChannelContext; object syncRoot = new object(); [SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode, Justification = "Instantiated by ASP.NET")] protected BaseAppDomainProtocolHandler(string protocolId) : base() { this.protocolId = protocolId; } object ThisLock { get { return this.syncRoot; } } protected void OnMessageReceived() { try { IListenerChannelCallback callback = this.listenerChannelCallback; if (callback != null) { callback.ReportMessageReceived(); } } catch (COMException exception) { if (DiagnosticUtility.ShouldTraceWarning) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning); } // The listener adapter might have gone away. Ignore the error. } } // Start per-process listening for messages public override void StartListenerChannel(IListenerChannelCallback listenerChannelCallback) { Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel()"); if (listenerChannelCallback == null) { DiagnosticUtility.DebugAssert("listenerChannelCallback is null"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } this.listenerChannelCallback = listenerChannelCallback; int listenerChannelDataLength = listenerChannelCallback.GetBlobLength(); byte[] listenerChannelData = new byte[listenerChannelDataLength]; listenerChannelCallback.GetBlob(listenerChannelData, ref listenerChannelDataLength); Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel() GetBlob() contains " + listenerChannelDataLength + " bytes"); listenerChannelContext = ListenerChannelContext.Hydrate(listenerChannelData); Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel() calling OnStart()"); #if DEBUG // Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel() waiting for you to attach the debugger to " + Process.GetCurrentProcess().ProcessName + " Pid: " + Process.GetCurrentProcess().Id); // for (int sleepCount = 0; sleepCount < 30 && !Debugger.IsAttached && !ListenerUnsafeNativeMethods.IsDebuggerPresent(); sleepCount++) { Thread.Sleep(500); } Debugger.Break(); #endif try { OnStart(); listenerChannelCallback.ReportStarted(); Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel() called ReportStarted()"); } catch (CommunicationException exception) { Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel() failed in OnStart():\r\n" + exception); DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.WebHost, EventLogEventId.WebHostFailedToListen, listenerChannelContext.AppKey, this.protocolId, TraceUtility.CreateSourceString(this), exception.ToString()); throw; } } protected virtual void OnStart() { } protected virtual void OnStop() { } public override void StopProtocol(bool immediate) { Debug.Print("BaseAppDomainProtocolHandler.StopProtocol() immediate: " + immediate + " calling ReportStopped()"); Stop(); HostingEnvironment.UnregisterObject(this); } public override void StopListenerChannel(int listenerChannelId, bool immediate) { Debug.Print("BaseAppDomainProtocolHandler.StopListenerChannel() listenerChannelId: " + listenerChannelId + " immediate: " + immediate + " calling ReportStopped()"); if (listenerChannelId != listenerChannelContext.ListenerChannelId) { DiagnosticUtility.DebugAssert("Invalid ListenerChannel ID!"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } Stop(); } void Stop() { lock (ThisLock) { if (this.listenerChannelCallback != null) { OnStop(); this.listenerChannelCallback.ReportStopped(0); this.listenerChannelCallback = null; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel.WasHosting { using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.ServiceModel; using System.ServiceModel.Channels; using System.Web; using System.Web.Hosting; using System.ServiceModel.Activation; using System.ServiceModel.Diagnostics; using System.Runtime; using System.Runtime.InteropServices; abstract class BaseAppDomainProtocolHandler : AppDomainProtocolHandler { public readonly static TimeSpan DefaultStopTimeout = TimeSpan.FromSeconds(30); string protocolId; IListenerChannelCallback listenerChannelCallback; protected ListenerChannelContext listenerChannelContext; object syncRoot = new object(); [SuppressMessage(FxCop.Category.Performance, FxCop.Rule.AvoidUncalledPrivateCode, Justification = "Instantiated by ASP.NET")] protected BaseAppDomainProtocolHandler(string protocolId) : base() { this.protocolId = protocolId; } object ThisLock { get { return this.syncRoot; } } protected void OnMessageReceived() { try { IListenerChannelCallback callback = this.listenerChannelCallback; if (callback != null) { callback.ReportMessageReceived(); } } catch (COMException exception) { if (DiagnosticUtility.ShouldTraceWarning) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning); } // The listener adapter might have gone away. Ignore the error. } } // Start per-process listening for messages public override void StartListenerChannel(IListenerChannelCallback listenerChannelCallback) { Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel()"); if (listenerChannelCallback == null) { DiagnosticUtility.DebugAssert("listenerChannelCallback is null"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } this.listenerChannelCallback = listenerChannelCallback; int listenerChannelDataLength = listenerChannelCallback.GetBlobLength(); byte[] listenerChannelData = new byte[listenerChannelDataLength]; listenerChannelCallback.GetBlob(listenerChannelData, ref listenerChannelDataLength); Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel() GetBlob() contains " + listenerChannelDataLength + " bytes"); listenerChannelContext = ListenerChannelContext.Hydrate(listenerChannelData); Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel() calling OnStart()"); #if DEBUG // Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel() waiting for you to attach the debugger to " + Process.GetCurrentProcess().ProcessName + " Pid: " + Process.GetCurrentProcess().Id); // for (int sleepCount = 0; sleepCount < 30 && !Debugger.IsAttached && !ListenerUnsafeNativeMethods.IsDebuggerPresent(); sleepCount++) { Thread.Sleep(500); } Debugger.Break(); #endif try { OnStart(); listenerChannelCallback.ReportStarted(); Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel() called ReportStarted()"); } catch (CommunicationException exception) { Debug.Print("BaseAppDomainProtocolHandler.StartListenerChannel() failed in OnStart():\r\n" + exception); DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.WebHost, EventLogEventId.WebHostFailedToListen, listenerChannelContext.AppKey, this.protocolId, TraceUtility.CreateSourceString(this), exception.ToString()); throw; } } protected virtual void OnStart() { } protected virtual void OnStop() { } public override void StopProtocol(bool immediate) { Debug.Print("BaseAppDomainProtocolHandler.StopProtocol() immediate: " + immediate + " calling ReportStopped()"); Stop(); HostingEnvironment.UnregisterObject(this); } public override void StopListenerChannel(int listenerChannelId, bool immediate) { Debug.Print("BaseAppDomainProtocolHandler.StopListenerChannel() listenerChannelId: " + listenerChannelId + " immediate: " + immediate + " calling ReportStopped()"); if (listenerChannelId != listenerChannelContext.ListenerChannelId) { DiagnosticUtility.DebugAssert("Invalid ListenerChannel ID!"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false); } Stop(); } void Stop() { lock (ThisLock) { if (this.listenerChannelCallback != null) { OnStop(); this.listenerChannelCallback.ReportStopped(0); this.listenerChannelCallback = null; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AnnotationDocumentPaginator.cs
- DataSourceSelectArguments.cs
- RepeaterItem.cs
- CorrelationManager.cs
- LogPolicy.cs
- Light.cs
- TTSEngineProxy.cs
- UIAgentCrashedException.cs
- ComPlusDiagnosticTraceRecords.cs
- NamedPipeProcessProtocolHandler.cs
- ConnectionConsumerAttribute.cs
- TokenBasedSet.cs
- InstancePersistence.cs
- Compensation.cs
- DataGridBeginningEditEventArgs.cs
- securitycriticaldata.cs
- SrgsDocument.cs
- FontWeights.cs
- TextParagraph.cs
- ZipIOLocalFileDataDescriptor.cs
- EntitySqlQueryCacheEntry.cs
- NativeWrapper.cs
- RuntimeConfigurationRecord.cs
- BaseDataList.cs
- RulePatternOps.cs
- PolicyManager.cs
- XmlCDATASection.cs
- UnsafeNativeMethodsPenimc.cs
- ObjectPersistData.cs
- PasswordBoxAutomationPeer.cs
- WindowsGraphics2.cs
- PaintEvent.cs
- TypeProvider.cs
- ManagedFilter.cs
- SmiTypedGetterSetter.cs
- QueryContinueDragEventArgs.cs
- ObjectAssociationEndMapping.cs
- AncestorChangedEventArgs.cs
- WebSysDisplayNameAttribute.cs
- DataControlLinkButton.cs
- Point3DCollection.cs
- GridViewUpdateEventArgs.cs
- SchemaDeclBase.cs
- DataGridSortCommandEventArgs.cs
- Font.cs
- DefinitionUpdate.cs
- OutputWindow.cs
- FocusTracker.cs
- LocalBuilder.cs
- InternalConfigEventArgs.cs
- GlobalizationSection.cs
- StyleXamlParser.cs
- CachedRequestParams.cs
- ValueType.cs
- CLRBindingWorker.cs
- HtmlControlAdapter.cs
- EditorAttributeInfo.cs
- HtmlFormAdapter.cs
- ImageIndexConverter.cs
- PermissionSet.cs
- CellQuery.cs
- Activation.cs
- TraceHelpers.cs
- TrustSection.cs
- HttpPostedFile.cs
- ImageListStreamer.cs
- ContainerUtilities.cs
- SystemResourceHost.cs
- CmsInterop.cs
- SafeNativeHandle.cs
- WebPartEditVerb.cs
- AttributeCollection.cs
- PageSetupDialog.cs
- MulticastNotSupportedException.cs
- BulletChrome.cs
- ElementUtil.cs
- ReferenceSchema.cs
- Panel.cs
- ZeroOpNode.cs
- PrePrepareMethodAttribute.cs
- AlgoModule.cs
- Rotation3DAnimationBase.cs
- DesignerHelpers.cs
- PersistencePipeline.cs
- InProcStateClientManager.cs
- GZipObjectSerializer.cs
- CollectionView.cs
- EpmTargetPathSegment.cs
- BuiltInExpr.cs
- DesignerVerbToolStripMenuItem.cs
- HttpPostedFileBase.cs
- MruCache.cs
- MsdtcClusterUtils.cs
- SourceElementsCollection.cs
- PackUriHelper.cs
- IIS7WorkerRequest.cs
- BaseParagraph.cs
- XmlSignificantWhitespace.cs
- WindowsGraphics2.cs
- SerializationHelper.cs