public static SearchCollection Load(string fileName) { var collection = new SearchCollection(); var xdoc = XDocument.Load(fileName); collection.AddRange(xdoc.Descendants("search").Select(xs => new Search(xs.Value))); return(collection); }
protected void Monitor() { while (ProcessorAlive) { Sleep(5000); if (DateTime.Now.Second <= 5) { SearchCollection = SearchCollection.Load(SEARCHESFILENAME); } } }
public void Start() { ProcessorAlive = true; ExecutionPath = System.Reflection.Assembly.GetExecutingAssembly().Location; ExecutionPath = System.IO.Path.GetDirectoryName(ExecutionPath) + "\\"; NewTorrents = new TorrentCollection(); ProcessedTorrents = new TorrentCollection(ExecutionPath + "ProcessedTorrents.xml"); SearchCollection = SearchCollection.Load(ExecutionPath + SEARCHESFILENAME); Url = ConfigurationManager.AppSettings["Url"]; if (String.IsNullOrWhiteSpace(Url)) { throw new Exception("No URL supplied!"); } TorrentPath = ConfigurationManager.AppSettings["TorrentPath"]; if (!Directory.Exists(TorrentPath)) { Directory.CreateDirectory(TorrentPath); } _stopEvent = new ManualResetEvent(false); //Create threads _collectionThread = new Thread(Collection) { IsBackground = true, Name = "CollectionThread" }; _processingThread = new Thread(Processing) { IsBackground = true, Name = "ProcessThread" }; //Start Threads _collectionThread.Start(); _processingThread.Start(); }