Exemplo n.º 1
0
 /// <summary>
 /// Create a worker thread, start it, Execute the runnable and terminate
 /// the thread (one time execution).
 /// </summary>
 internal WorkerThread(SimpleThreadPool tp, string name,
                       ThreadPriority prio, bool isDaemon, IThreadRunnable runnable)
     : base(name)
 {
     this.tp       = tp;
     this.runnable = runnable;
     Priority      = prio;
     IsBackground  = isDaemon;
 }
Exemplo n.º 2
0
            /// <summary>
            /// Create a worker thread, start it, Execute the runnable and terminate
            /// the thread (one time execution).
            /// </summary>
            internal WorkerThread(
                SimpleThreadPool tp,
                string name,
                ThreadPriority prio,
                bool isDaemon,
                Action runnable = null)
                : base(name)
            {
                this.tp       = tp;
                this.runnable = runnable;
                if (runnable != null)
                {
                    runOnce = true;
                }
#if THREAD_PRIORITY
                Priority = prio;
#endif // THREAD_PRIORITY
                IsBackground = isDaemon;
            }
        public void TestPlugins()
        {
            StringBuilder result = new StringBuilder();

            IDictionary<string, ISchedulerPlugin> data = new Dictionary<string, ISchedulerPlugin>();
            data["TestPlugin"] = new TestPlugin(result);

            IThreadPool threadPool = new SimpleThreadPool(1, ThreadPriority.Normal);
            threadPool.Initialize();
            DirectSchedulerFactory.Instance.CreateScheduler(
                "MyScheduler", "Instance1", threadPool,
                new RAMJobStore(), data,
                TimeSpan.Zero);

            IScheduler scheduler = DirectSchedulerFactory.Instance.GetScheduler("MyScheduler");
            scheduler.Start();
            scheduler.Shutdown();

            Assert.AreEqual("TestPlugin|MyScheduler|Start|Shutdown", result.ToString());
        }
 /// <summary>
 /// Create a worker thread and start it. Waiting for the next Runnable,
 /// executing it, and waiting for the next Runnable, until the Shutdown
 /// flag is set.
 /// </summary>
 internal WorkerThread(SimpleThreadPool tp, string name,
                       ThreadPriority prio, bool isDaemon)
     : this(tp, name, prio, isDaemon, null)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create a worker thread, start it, Execute the runnable and terminate
 /// the thread (one time execution).
 /// </summary>
 internal WorkerThread(SimpleThreadPool tp, string name,
                       ThreadPriority prio, bool isDaemon, IThreadRunnable runnable)
     : base(name)
 {
     this.tp = tp;
     this.runnable = runnable;
     if (runnable != null)
     {
         runOnce = true;
     }
     Priority = prio;
     IsBackground = isDaemon;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Create a worker thread and start it. Waiting for the next Runnable,
 /// executing it, and waiting for the next Runnable, until the Shutdown
 /// flag is set.
 /// </summary>
 internal WorkerThread(SimpleThreadPool tp, string name,
                       ThreadPriority prio, bool isDaemon)
     : this(tp, name, prio, isDaemon, null)
 {
 }
Exemplo n.º 7
-1
 /// <summary>
 /// Creates an in memory job store (<see cref="RAMJobStore" />)
 /// The thread priority is set to Thread.NORM_PRIORITY
 /// </summary>
 /// <param name="maxThreads">The number of threads in the thread pool</param>
 public virtual void CreateVolatileScheduler(int maxThreads)
 {
     SimpleThreadPool threadPool = new SimpleThreadPool(maxThreads, ThreadPriority.Normal);
     threadPool.Initialize();
     IJobStore jobStore = new RAMJobStore();
     CreateScheduler(threadPool, jobStore);
 }