예제 #1
0
        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);
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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;
        }