protected override void OnStart(string[] args)
        {
            //init counter
            PerfCounterAsync.InitPerformanceCounter();

            //start watcher
            InitializeWatcher();
        }
        /// <summary>
        /// save all message in the selected dump layer
        /// </summary>
        /// <param name="ServiceInstanceID"></param>
        /// <param name="MessagesID"></param>
        /// <param name="btArtifact"></param>
        private static void SaveMessages(Guid ServiceInstanceID, IEnumerable <Guid> MessagesID, BTArtifactLogic btArtifact)
        {
            LogHelper.WriteInfo(ResourceLogic.GetString(ResourceKeyName.MessageSaving));
            //retrieve the right layer
            ITransportLayer accessLayer = ConfigParameter.GettingTheRightLayer();

            foreach (Guid gu in MessagesID)
            {
                //retrieving the message
                String sMessage = btArtifact.GetMessageBodyByMessageId(gu, ServiceInstanceID);
                //save the message
                accessLayer.SendMessage(sMessage, gu);
                //updatecounter
                PerfCounterAsync.UpdateStatistic();
            }
            LogHelper.WriteInfo(ResourceLogic.GetString(ResourceKeyName.MessageSaved));
        }
        static void Main()
        {
            try
            {
                //check configuration before starting
                if (ConfigParameter.IsConfigurationOk())
                {
#if DEBUG
                    LogHelper.WriteInfo(ResourceLogic.GetString(ResourceKeyName.DebugMode));

                    //init counter
                    PerfCounterAsync.InitPerformanceCounter();

                    InitializeWatcher();
                    Console.ReadLine();
                    PerfCounterAsync.Close();
#else
                    System.ServiceProcess.ServiceBase[] ServicesToRun;

                    // More than one user service may run in the same process. To add
                    // another service to this process, change the following line to
                    // create a second service object. For example,
                    //
                    //   ServicesToRun = New System.ServiceProcess.ServiceBase[] {new Service1(), new MySecondUserService()};
                    //
                    ServicesToRun = new System.ServiceProcess.ServiceBase[] { new ZombieManagementService() };


                    System.ServiceProcess.ServiceBase.Run(ServicesToRun);
#endif
                }
                else
                {
                    LogHelper.WriteError(ResourceLogic.GetString(ResourceKeyName.ErrorValidation));
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ResourceLogic.GetString(ResourceKeyName.StopService));
                LogHelper.WriteError(ex);
            }
        }
 public override void Uninstall(IDictionary savedState)
 {
     base.Uninstall(savedState);
     PerfCounterAsync.DeleteCategory();
 }
 public override void Install(IDictionary stateSaver)
 {
     base.Install(stateSaver);
     PerfCounterAsync.CreateCategory();
 }
        protected override void OnStop()
        {
            watcher.Stop();

            PerfCounterAsync.Close();
        }