public void SetUp() { wh = new ManualResetEventSlim(); var schedulerDelegate = new SchedulerDelegate(); schedulerDelegate.OnStoppedAction = () => wh.Set(); var scheduler = new KayakScheduler(schedulerDelegate); var serverDelegate = new ServerDelegate(); server = KayakServer.Factory.Create(serverDelegate, scheduler); }
static void Main(string[] args) { Repository.CreateDbIfNotExists(); var scheduler = new KayakScheduler(new SchedulerDelegate()); scheduler.Post(() => KayakServer.Factory .CreateHttp(new RequestDelegate()) .Listen(new IPEndPoint(IPAddress.Any, 8080))); // runs scheduler on calling thread. this method will block until // someone calls Stop() on the scheduler. scheduler.Start(); }
static void Main(string[] args) { #if DEBUG Debug.Listeners.Add(new TextWriterTraceListener(Console.Out)); Debug.AutoFlush = true; #endif var scheduler = new KayakScheduler(new SchedulerDelegate()); scheduler.Post(() => { KayakServer.Factory .CreateHttp(new RequestDelegate()) .Listen(new IPEndPoint(IPAddress.Any, 8080)); }); // runs scheduler on calling thread. this method will block until // someone calls Stop() on the scheduler. scheduler.Start(); }
void Dispatch() { current = this; wh = new ManualResetEventSlim(); while (true) { Task outTask = null; if (queue.TryDequeue(out outTask)) { Debug.WriteLine("--- Executing Task ---"); TryExecuteTask(outTask); Debug.WriteLine("--- Done Executing Task ---"); if (stopped) { stopped = false; dispatch = null; queue = new ConcurrentQueue<Task>(); Debug.WriteLine("Scheduler stopped."); del.OnStop(this); break; } } else { wh.Wait(); wh.Reset(); } } stopped = false; dispatch = null; wh.Dispose(); wh = null; current = null; }