ActivationService.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / SMSvcHost / System / ServiceModel / Activation / ActivationService.cs / 1 / ActivationService.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.ServiceModel.Activation 
{
    using System; 
    using System.Diagnostics; 
    using System.ServiceProcess;
    using System.ServiceModel; 
    using System.ServiceModel.Diagnostics;
    using System.ServiceModel.Activation.Diagnostics;
    using System.ServiceModel.Channels;
    using System.Threading; 

    abstract class ActivationService : ServiceBase, IActivationService 
    { 
        ListenerAdapter listenerAdapter;
        string protocolName; 
        bool isPaused;

        protected ActivationService(string serviceName, string protocolName)
        { 
            this.protocolName = protocolName;
            ServiceName = serviceName; 
            CanHandlePowerEvent = false; 
            AutoLog = false;
            CanStop = true; 
            CanPauseAndContinue = true;
            CanShutdown = true;
        }
 
        public bool IsPaused { get { return isPaused; } }
        public string ActivationServiceName { get { return this.ServiceName; } } 
        public string ProtocolName { get { return protocolName; } } 

        public IActivatedMessageQueue CreateQueue(ListenerAdapter la, App app) 
        {
            return new ActivatedMessageQueue(la, app);
        }
 
        public IActivatedMessageQueue FindQueue(int queueId)
        { 
            return ActivatedMessageQueue.Find(queueId); 
        }
 
        protected override void OnContinue()
        {
            if (DiagnosticUtility.ShouldTraceInformation)
            { 
                ListenerTraceUtility.TraceEvent(TraceEventType.Information, TraceCode.ServiceContinue, this);
            } 
 
            isPaused = false;
        } 

        protected override void OnPause()
        {
            if (DiagnosticUtility.ShouldTraceInformation) 
            {
                ListenerTraceUtility.TraceEvent(TraceEventType.Information, TraceCode.ServicePause, this); 
            } 

            isPaused = true; 
        }

        protected override void OnShutdown()
        { 
            if (DiagnosticUtility.ShouldTraceInformation)
            { 
                ListenerTraceUtility.TraceEvent(TraceEventType.Information, TraceCode.ServiceShutdown, this); 
            }
 
            Shutdown();
            Stop();
        }
 
        protected override void OnStop()
        { 
            if (DiagnosticUtility.ShouldTraceInformation) 
            {
                ListenerTraceUtility.TraceEvent(TraceEventType.Information, TraceCode.ServiceStop, this); 
            }

            Shutdown();
        } 

        protected override void OnStart(string[] args) 
        { 
            if (DiagnosticUtility.ShouldTraceInformation)
            { 
                ListenerTraceUtility.TraceEvent(TraceEventType.Information, TraceCode.ServiceStart, this);
            }

#if DEBUG 
            if (DebuggableService.DelayStart(ServiceName))
            { 
                (new Thread(new ThreadStart(Start))).Start(); 
                return;
            } 
#endif
            Start();
        }
 
        void Start()
        { 
#if DEBUG 
            DebuggableService.WaitForDebugger(ServiceName);
#endif 
            if (!SMSvcHost.IsWebhostSupported)
            {
                const int ERROR_NOT_SUPPORTED = 50;
                this.ExitCode = ERROR_NOT_SUPPORTED; 
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.ServiceRequiresWas)));
            } 
            isPaused = false; 
            listenerAdapter = new ListenerAdapter(this);
            listenerAdapter.Open(); 
        }

        void Shutdown()
        { 
            listenerAdapter.Close();
        } 
 
        public void StopService()
        { 
            Stop();
        }
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK