private void btnTag_Click(object sender, EventArgs e) { ThreadHandler.Reset(); // save current configuration Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings.Remove("input"); config.AppSettings.Settings.Add("input", txtInput.Text); config.AppSettings.Settings.Remove("includeSubfolders"); config.AppSettings.Settings.Add("includeSubfolders", chkIncludeSubfolders.Checked ? "true" : "false"); config.AppSettings.Settings.Remove("overwriteFiles"); config.AppSettings.Settings.Add("overwriteFiles", chkOverwriteFiles.Checked ? "true" : "false"); config.AppSettings.Settings.Remove("output"); config.AppSettings.Settings.Add("output", txtOutput.Text); config.AppSettings.Settings.Remove("taggerFile"); config.AppSettings.Settings.Add("taggerFile", txtTaggerFile.Text); config.AppSettings.Settings.Remove("lemmatizerFile"); config.AppSettings.Settings.Add("lemmatizerFile", txtLemmatizerFile.Text); config.Save(ConfigurationSaveMode.Modified); // prepare form DisableForm(); txtStatus.Clear(); // invoke tagger mThread = new Thread(new ThreadStart(delegate() { ArrayList <string> settings = new ArrayList <string>(new string[] { "-v", "-t" }); if (chkOverwriteFiles.Checked) { settings.Add("-o"); } if (chkIncludeSubfolders.Checked) { settings.Add("-s"); } if (txtLemmatizerFile.Text.Trim() != "") { settings.Add("-lem:" + txtLemmatizerFile.Text); } settings.AddRange(new string[] { txtInput.Text, txtTaggerFile.Text, txtOutput.Text }); PosTaggerTag.Tag(settings.ToArray()); GC.Collect(); // this closes all open files by invoking finalizers on readers and writers Invoke(new ThreadStart(delegate() { EnableForm(); })); })); mThread.Start(); }