private void OutCastQueriesBgWorkerWork(object sender, DoWorkEventArgs e) { _outCastAvgList.Clear(); using (var writer = new StreamWriter(OutCastOutputFile)) { using (var reader = new StreamReader(OutCastCases)) { var ct = 0; var input = reader.ReadToEnd(); var inputLines = Regex.Split(input, "\r\n|\r|\n"); var totalInput = inputLines.Length; for (int i = 1; i < totalInput; i++) { var nouns = inputLines[i].Split(','); ct++; try { var watch = Stopwatch.StartNew(); var outCastedNoun = _wordNet.OutCastNoun(nouns.ToList(), NounCastedProgressReport, "OutCast-Noun"); watch.Stop(); _bgWorker.ReportProgress(ct * 100 / (totalInput - 1), new object[] { ct, watch.ElapsedMilliseconds, $"Working..{ct} / {totalInput}", outCastedNoun }); _outCastAvgList.Add(watch.ElapsedMilliseconds); writer.WriteLine(outCastedNoun); } catch (Exception ex) { LogEvent($"Error ocurred\n{ex.Message},\n{ex.StackTrace}."); } } } } }