Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / WasHosting / System / ServiceModel / WasHosting / BaseAppDomainProtocolHandler.cs / 1 / BaseAppDomainProtocolHandler.cs
//---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel.WasHosting { using System; using System.Diagnostics; 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.InteropServices; abstract class BaseAppDomainProtocolHandler : AppDomainProtocolHandler { string protocolId; IListenerChannelCallback listenerChannelCallback; protected ListenerChannelContext listenerChannelContext; object syncRoot = new object(); 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, DiagnosticTrace.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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FontResourceCache.cs
- MetafileHeaderWmf.cs
- SizeAnimationBase.cs
- ExtendedPropertyDescriptor.cs
- PolygonHotSpot.cs
- SqlConnection.cs
- SiblingIterators.cs
- CompilationUnit.cs
- DetectRunnableInstancesTask.cs
- LocatorPartList.cs
- OperandQuery.cs
- Maps.cs
- VirtualizingStackPanel.cs
- EditorPartDesigner.cs
- Int64.cs
- HttpInputStream.cs
- MailHeaderInfo.cs
- BitmapEffectInputConnector.cs
- ISAPIWorkerRequest.cs
- ServiceModelEnhancedConfigurationElementCollection.cs
- SqlClientWrapperSmiStreamChars.cs
- SqlBooleanMismatchVisitor.cs
- GraphicsPath.cs
- ValueConversionAttribute.cs
- login.cs
- ObfuscationAttribute.cs
- BooleanKeyFrameCollection.cs
- TextElementAutomationPeer.cs
- SecUtil.cs
- TreeNodeCollection.cs
- RightsManagementEncryptionTransform.cs
- securitycriticaldataClass.cs
- StylusEditingBehavior.cs
- Site.cs
- Propagator.ExtentPlaceholderCreator.cs
- TypeCollectionDesigner.xaml.cs
- InkCanvasSelection.cs
- PresentationSource.cs
- ClientOptions.cs
- EditorZone.cs
- BevelBitmapEffect.cs
- GroupQuery.cs
- SystemWebSectionGroup.cs
- FontFamily.cs
- KeyTimeConverter.cs
- ObjectResult.cs
- DataComponentMethodGenerator.cs
- CodeMemberEvent.cs
- UrlRoutingModule.cs
- DeflateInput.cs
- DateTimeFormatInfo.cs
- UnknownWrapper.cs
- ClockController.cs
- OutputCacheProfileCollection.cs
- XmlnsDictionary.cs
- TextDocumentView.cs
- grammarelement.cs
- BitmapEffectInput.cs
- FigureHelper.cs
- FileChangesMonitor.cs
- DbProviderServices.cs
- TemplatePartAttribute.cs
- FixedPosition.cs
- QilGeneratorEnv.cs
- HttpStreamXmlDictionaryWriter.cs
- RequestCachePolicyConverter.cs
- XPathDescendantIterator.cs
- DataGridViewCellMouseEventArgs.cs
- LocatorManager.cs
- SelectionProviderWrapper.cs
- RTTrackingProfile.cs
- AudioLevelUpdatedEventArgs.cs
- IdentityHolder.cs
- SafeBitVector32.cs
- TreeViewAutomationPeer.cs
- CubicEase.cs
- WebPartDescription.cs
- BindingList.cs
- RoleServiceManager.cs
- BackgroundWorker.cs
- XmlSchemaSet.cs
- XmlCountingReader.cs
- HyperLinkField.cs
- RouteParameter.cs
- SecurityTokenSerializer.cs
- DbParameterCollectionHelper.cs
- SafeNativeMethodsMilCoreApi.cs
- WorkflowElementDialog.cs
- NullableFloatAverageAggregationOperator.cs
- WebUtil.cs
- EncryptedPackage.cs
- ArgumentOutOfRangeException.cs
- Scalars.cs
- Translator.cs
- RepeaterCommandEventArgs.cs
- WorkflowElementDialog.cs
- HierarchicalDataSourceConverter.cs
- ClaimSet.cs
- MainMenu.cs
- DataReceivedEventArgs.cs