Main Page | Class Hierarchy | Class List | File List | Class Members

BackgroundFetcher.cs

00001 using System;
00002 using System.Threading;
00003 using Common;
00004 
00005 namespace Server
00006 {
00010         public class BackgroundFetcher  {
00011                 MCP masterControl; 
00012                 HTTPObjectQueue fetchQueue;
00013                 Thread processingThread;
00014 
00015                 public BackgroundFetcher(MCP masterControl)     {
00016                         this.masterControl = masterControl;
00017                         fetchQueue = new HTTPObjectQueue();
00018                         processingThread = new Thread(new ThreadStart(run));
00019                 }
00020 
00021                 public void AddToFetchQueue(HTTPRequestQueueObject request) {
00022                         fetchQueue.EnqueueBlocking(request);
00023                 }
00024 
00025                 public void Start() {
00026                         processingThread.Start();
00027                 }
00028 
00029                 public void Stop() {
00030                         processingThread.Abort();
00031                 }
00032 
00033                 void run() {
00034                         try {
00035                                 while(true) {
00036                                         HTTPRequestQueueObject request = (HTTPRequestQueueObject)fetchQueue.DequeueBlocking();
00037                                         Console.WriteLine("- Background fetching {0}", request.URI);
00038                                         HTTPResponse response = masterControl.ServiceHTTPRequest(request);
00039                                         masterControl.SendResponse(response, request, true);
00040                                         Thread.Sleep(10);
00041                                 }
00042                         } catch (ThreadAbortException) {
00043                                 Console.WriteLine("[Background Fetcher shut down]");
00044                         }
00045                 }
00046         }
00047 }

Generated on Mon May 8 22:07:27 2006 by  doxygen 1.3.9.1