public void NoThreads() { frm_settings fs = new frm_settings(); int metawords = (int)fs.numericUpDown1.Value; int count = Book.GetCount("GetCountBooks"); PreProcess LogResults = new PreProcess(ComparingTxt, Convert.ToInt32(numGram.Value), metawords); LogResults.ScanFilesReader = Book.GetThesis("GetRangeBook", 1, count); LogResults.SearchSimilarity(); }
public void ThredingFiles() { Thread[] threads; PreProcess[] LogResults; int rate = 0; frm_settings fs = new frm_settings(); int metawords = (int)fs.numericUpDown1.Value; int count = Book.GetCount("GetCountBooks"); double r = count * 0.5;// thread count if (r > 0 && r < 1) { r = 1; } rate = (int)r; int start = 1; int end = count / rate;; threads = new Thread[rate]; LogResults = new PreProcess[rate]; for (int i = 0; i < threads.Length; ++i) { LogResults[i] = new PreProcess(ComparingTxt, Convert.ToInt32(numGram.Value), metawords); LogResults[i].ScanFilesReader = Book.GetThesis("GetRangeBook", start, end); threads[i] = new Thread(new ThreadStart(LogResults[i].SearchSimilarity)); if (!threads[i].IsAlive) { threads[i].Start(); } start += count / rate; if (count % 2 == 1 && i == threads.Length - 2) { end += count / rate + 1; } else { end += count / rate; } } for (int i = 0; i < threads.Length; i++) { threads[i].Join(); } }