private bool AddURLToList(Imageboard imageboard) { if (imageboard == null) { return(false); } if (imageboard.isBoard()) { lock (boardLock) { ListBoards.Add(imageboard); updateDataSource(typeURL.board); } } else { lock (threadLock) { ListThreads.Add(imageboard); updateDataSource(typeURL.thread); } } return(true); }
private void ScanThread() { lock (threadLock) { //Removes 404'd threads foreach (Imageboard imB in ListThreads.ToArray()) { if (imB.isGone()) { ListThreads.Remove(imB); updateDataSource(typeURL.thread); if (General.saveOnClose) { General.writeURLs(ListBoards, ListThreads); } } } } lock (boardLock) { //Searches for new threads on the watched boards foreach (Imageboard imB in ListBoards) { string[] Threads = { }; try { Threads = imB.getThreads(); } catch (Exception exep) { } foreach (string thread in Threads) { Imageboard newImageboard = General.createNewIMB(thread, false); if (newImageboard != null && isUnique(newImageboard.getURL(), ListThreads)) { lock (threadLock) { ListThreads.Add(newImageboard); updateDataSource(typeURL.thread); } } } } } lock (threadLock) { //Download threads foreach (Imageboard imB in ListThreads) { ThreadPool.QueueUserWorkItem(new WaitCallback(imB.download)); } } }
private void frmMain_Load(object sender, EventArgs e) { General.loadSettings(); // load settings on startup if (!General.minimizeToTray) // if trayicon deactivated { nfTray.Visible = false; // hide it } scnTimer.Enabled = false; // disable timer scnTimer.Interval = General.timer; // set interval scnTimer.Tick += new EventHandler(this.scan); // when Timer ticks call scan() ThreadPool.SetMaxThreads(Environment.ProcessorCount, Environment.ProcessorCount); if (General.firstStart) { FirstStart tFirstStart = new FirstStart(); // if first start, show first start message tFirstStart.ShowDialog(); } if (General.saveOnClose) // if enabled load URLs from file { string boards = General.loadURLs(true); string threads = General.loadURLs(false); // load threads if (!String.IsNullOrWhiteSpace(boards)) { lock (boardLock) { string[] URLs = boards.Split('\n'); for (int i = 0; i < URLs.Length - 1; i++) { Imageboard newImageboard = General.createNewIMB(URLs[i], true); // and add them ListBoards.Add(newImageboard); } } } if (!String.IsNullOrWhiteSpace(threads)) { lock (threadLock) { string[] URLs = threads.Split('\n'); for (int i = 0; i < URLs.Length - 1; i++) { Imageboard newImageboard = General.createNewIMB(URLs[i], false); ListThreads.Add(newImageboard); } } } lbBoards.DataSource = ListBoards; lbThreads.DataSource = ListThreads; scnTimer.Enabled = true; // activate the timer scan(null, null); // and start scanning } }
private void AddUrl(string url, bool board) { Imageboard newImageboard = General.createNewIMB(url, board); if (newImageboard != null) { if (isUnique(newImageboard.getURL(), ListThreads)) { if (board) { lock (boardLock) { ListBoards.Add(newImageboard); updateDataSource(typeURL.board); } } else { lock (threadLock) { ListThreads.Add(newImageboard); updateDataSource(typeURL.thread); } } } else { MessageBox.Show("URL is already in queue!"); return; } } else { MessageBox.Show("Corrupt URL, unsupported website or not a board/thread!"); edtURL.Text = ""; return; } if (!scnTimer.Enabled) { scnTimer.Enabled = true; } if (General.saveOnClose) { General.writeURLs(ListBoards, ListThreads); } scan(null, null); }