/// <summary> /// This is called by the build process thread to update the main /// window with information about its progress. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void buildProcess_BuildProgress(object sender, BuildProgressEventArgs e) { if (this.InvokeRequired) { // Ignore it if we've already shut down if (!this.IsDisposed) { this.Invoke(new EventHandler <BuildProgressEventArgs>( buildProcess_BuildProgress), new object[] { sender, e }); } } else { if (e.BuildStep < BuildStep.Completed) { StatusBarTextProvider.UpdateProgress((int)e.BuildStep); } if (Settings.Default.VerboseLogging || e.BuildStep == BuildStep.Failed) { txtOutput.AppendText(e.Message); txtOutput.AppendText("\r\n"); } } }
/// <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(); }