private void timer1_Tick(object sender, EventArgs e) { if (closeForm) { timer1.Enabled = false; Close(); runLog = null; return; } if (newModelName != null) { modelName.Text = newModelName; newModelName = null; } lock (runLog) { if (runLog.LineCount() != lastLineCount) { lastLineCount = runLog.LineCount(); String lastLine = runLog.LastLine(); TrainingModelOutput.AppendText(lastLine + "\n"); } } }
private void LogMessageFlush() { String msg = LogMessageGetNext(); while (msg != null) { TrainingModelOutput.AppendText(msg); TrainingModelOutput.AppendText("\n"); msg = LogMessageGetNext(); } }
private void timer1_Tick(object sender, EventArgs e) { if (forceCancelation) { // We want to just kill the TrainingModel2 thread. By this time // the abort function should have been called in 'ForceCancelation'. // So we are just going to exit the program now. Thread.Sleep(200); if (trainingModelThread != null) { trainingModelThread.Priority = ThreadPriority.Lowest; trainingModelThread = null; } if (trainingModel != null) { trainingModel.CancelLoad(); } Close(); timer1.Enabled = false; return; } if (trainingModel != null) { LogMessageFlush(); String msg = logMessages.GetNextMsg(); if (msg != null) { TrainingModelOutput.AppendText(msg); TrainingModelOutput.AppendText("\n"); } } if (!trainingModelRunning) { timer1.Enabled = false; // The Training Model thread is done; if (cancelFlag) { LogMessageFlush(); if (!loadHasBeenCanceledDialogActive) { loadHasBeenCanceledDialogActive = true; MessageBox.Show("Training Model[" + trainingModelName + "] load has been canceled."); loadHasBeenCanceledDialogActive = false; } } else if (!validModel) { LogMessageFlush(); DialogResult dr = MessageBox.Show("Training Model[" + trainingModelName + "] failed to load; Press 'Yes' to see Log Messages.", "Training Model Status", MessageBoxButtons.YesNo ); if (dr == DialogResult.Yes) { Process proc = new Process(); proc.StartInfo.WorkingDirectory = @""; proc.StartInfo.FileName = "notepad.exe"; proc.StartInfo.Arguments = trainingModelLogFileName; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardOutput = false; proc.StartInfo.RedirectStandardError = true; proc.Start(); proc.WaitForExit(); proc.Close(); } } Close(); completionEvent(this); } } /* timer1_Tick*/