Exemple #1
0
        public override void Run()
        {
            var workers = new WorkerEntryPoint[]
            {
                new LogChangesToTableStorageWorkerRole(),
                new SaveToBlobStorageWorkerRole()
            };

            Run(workers);
        }
Exemple #2
0
        public override void Run()
        {
            var workers = new WorkerEntryPoint[]
            {
                new LogChangesToTableStorageWorkerRole(),
                new SaveToBlobStorageWorkerRole()
            };

            Run(workers);
        }
        /// <summary>
        /// Called from WebRole, bringing in workers to add to threads
        /// </summary>
        /// <param name="workers">WorkerEntryPoint[] arrayWorkers</param>
        public void Run(WorkerEntryPoint[] arrayWorkers)
        {
            this.workers = arrayWorkers;

            foreach (WorkerEntryPoint worker in this.workers)
            {
                worker.OnStart();
            }

            foreach (WorkerEntryPoint worker in this.workers)
            {
                this.threads.Add(new Thread(worker.ProtectedRun));
            }

            foreach (Thread thread in this.threads)
            {
                thread.Start();
            }

            while (!EventWaitHandle.WaitOne(0))
            {
                // Restart Dead Threads
                for (int i = 0; i < this.threads.Count; i++)
                {
                    if (!this.threads[i].IsAlive)
                    {
                        this.threads[i] = new Thread(this.workers[i].Run);
                        this.threads[i].Start();
                    }
                }

                EventWaitHandle.WaitOne(1000);
            }
        }