Пример #1
0
        /// <summary>
        ///     Invoked when obj started
        /// </summary>
        protected override void OnStart()
        {
            base.OnStart();

            Scheduler          = new TimerScheduler(this);
            CoroutineScheduler = New <CoroutineScheduler>(new ObjArg(this));
            CoroutineScheduler.Start();

            if (_workingQueue != null ||
                _workingThread != null)
            {
                Logger.Ins.Fatal("AutoXService being start more than once");
                return;
            }

            _workingQueue  = new BlockingCollection <IJob>(QueueCapacity);
            _workingThread = new Thread(WorkingProcedure)
            {
                Name = "AutoXService", IsBackground = true
            };
            // use background thread
            // see http://msdn.microsoft.com/en-us/library/h339syd0.aspx

            _workingThread.Start();
            Logger.Ins.Debug("Auto logic service started!");
        }
Пример #2
0
 /// <summary>
 /// Construct a new timer object.
 /// </summary>
 /// <param name="name">the timer's name</param>
 /// <param name="dueTime">when to begin this timer, in milliseconds.
 /// zero means start immediately</param>
 public Timer(string name, uint dueTime)
 {
     Name       = name;
     DueTime    = dueTime;
     _scheduler = GlobalVarPool.Ins.Service.Scheduler;
 }