Пример #1
0
 public void registerService(JService service)
 {
     lock (this)
     {
         service.Id = idCounter++;
     }
     ServiceList.Add(service.Id, service);
 }
Пример #2
0
        //Aborts thread without giving it chance to finish
        public void forceStopService(JService service)
        {
            Thread threadToEnd;

            try
            {
                ThreadList.TryGetValue(service.Id, out threadToEnd);
                threadToEnd.Abort();
                removeService(service);
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine("Force Stop " + service.Id + " Failed: " + e.ToString());
            }
        }
Пример #3
0
        public bool startService(JService service)
        {
            JService serviceToStart;
            Thread   threadStarted;

            try
            {
                ServiceList.TryGetValue(service.Id, out serviceToStart);
                threadStarted = new Thread(service.start);
                ThreadList.Add(service.Id, threadStarted);
                threadStarted.Start();
                return(true);
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine("Start Service " + service.Id + " Failed: " + e.ToString());
            }

            return(false);
        }
Пример #4
0
 public void removeService(JService service)
 {
     ThreadList.Remove(service.Id);
     ServiceList.Remove(service.Id);
 }