/// <summary> /// Cancel the current build process /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void miCancelBuild_Click(object sender, EventArgs e) { if (buildThread != null && buildThread.IsAlive) { try { this.Cursor = Cursors.WaitCursor; StatusBarTextProvider.UpdateProgress("Cancelling build..."); buildThread.Abort(); while (buildThread != null && !buildThread.Join(1000)) { Application.DoEvents(); } StatusBarTextProvider.ResetProgressBar(); System.Diagnostics.Debug.WriteLine("Thread stopped"); } finally { this.Cursor = Cursors.Default; buildThread = null; buildProcess = null; } } this.SetUIEnabledState(true); }
/// <summary> /// Utilize the status strip label and progress bar via the status bar /// text provider. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event argumnents</param> private void btnProgress_Click(object sender, EventArgs e) { StatusBarTextProvider.InitializeProgressBar(100); for (int i = 0; i < 100; i++) { StatusBarTextProvider.UpdateProgress(i + 1, String.Format("Step #{0}", i + 1)); System.Threading.Thread.Sleep(25); } StatusBarTextProvider.ResetProgressBar(); }
/// <summary> /// This is called by the build process thread to update the main /// window with the current build step. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void buildProcess_BuildStepChanged(object sender, BuildProgressEventArgs e) { string outputPath; if (this.InvokeRequired) { // Ignore it if we've already shut down or it hasn't // completed yet. if (!this.IsDisposed) { this.Invoke(new EventHandler <BuildProgressEventArgs>( buildProcess_BuildStepChanged), new object[] { sender, e }); } } else { if (!Settings.Default.VerboseLogging) { txtOutput.AppendText(e.BuildStep.ToString()); txtOutput.AppendText("\r\n"); } if (e.HasCompleted) { StatusBarTextProvider.ResetProgressBar(); this.SetUIEnabledState(true); // Save the output log filename and help filename on // completion if possible outputPath = buildProcess.OutputFolder; if (Directory.Exists(outputPath)) { lastOutputLog = buildProcess.LogFilename; } else { lastOutputLog = null; } // Store the help file filename so that it can be viewed // if it exists. if (e.BuildStep == BuildStep.Completed) { switch (project.HelpFileFormat) { case HelpFileFormat.HtmlHelp1x: case HelpFileFormat.Help1xAndHelp2x: outputPath += project.HtmlHelpName + ".chm"; break; case HelpFileFormat.HtmlHelp2x: outputPath += project.HtmlHelpName + ".hxs"; break; default: outputPath += "Index.html"; break; } if (File.Exists(outputPath)) { lastBuiltHelpFile = outputPath; } } buildThread = null; buildProcess = null; } } }