Generic progress dialog
Inheritance: System.Windows.Forms.Form
Ejemplo n.º 1
0
 /// <summary>
 /// Shows the progress dialog
 /// </summary>
 /// <param name="max">The maximum value. If less than or equal to 0, the progress bar will use the marquee animation</param>
 /// <param name="canCancel">if set to <c>true</c>, the user can cancel the operation. In this case, the <see cref="CancelEvent"/> must be handled</param>
 public static void Show(int max, bool canCancel)
 {
     instance = new ProgressDialog();
     instance.btnCancel.Enabled = canCancel;
     SetMax(max);
     
     thread = new Thread(new ThreadStart(LaunchForm));
     thread.IsBackground = true;
     thread.Start();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Stops and closes the progress dialog
        /// </summary>
        public static void Stop()
        {
            if (instance != null)
            {
                if (instance.InvokeRequired)
                {
                    StopCallback s = new StopCallback(Stop);
                    instance.Invoke(s);
                }
                else
                {
                    instance.Close();
                    instance.Dispose();
                    instance = null;
                }
            }

            if (thread != null)
            {
                Thread.Sleep(0);
                thread = null;
            }
        }