示例#1
0
 internal void StartServices()
 {
     foreach (ServiceThread service in _registeredServices)
     {
         try
         {
             service.ServiceStart();
             ThreadManager.ThreadStart(service, service.ServiceName(), System.Threading.ThreadPriority.Lowest);
         }
         catch (Exception err)
         {
             _logging.AddToLog(err, service.ToString());
         }
     }
 }
示例#2
0
        protected override bool Run(object parameters)
        {
            // if the thread has been cancelled then exit
            if (HasCancelled())
            {
                return(false);
            }

            List <Message> messages = new List <Message>();

            try
            {
                using (TimedLock.Lock(_lockObject))
                {
                    // copy all messages to the local list and clear it out,
                    // the service item can then process them as it see's fit
                    foreach (Message message in _serviceMessages)
                    {
                        messages.Add(message);
                    }

                    _serviceMessages.Clear();
                }

                if (!_serverManagerService.ServiceExecute(messages))
                {
                    return(false);
                }

                return(!HasCancelled());
            }
            catch (Exception error)
            {
                _logging.AddToLog(error, ToString());

                // add all message back to the list

                foreach (Message message in messages)
                {
                    AddMessage(message);
                }
            }

            return(!HasCancelled());
        }