Example #1
0
 /// <summary>
 /// Create a new AlertBoxForm with specified title, content and timeout.
 /// </summary>
 /// <param name="title">The title of the AlertBox.</param>
 /// <param name="content">The content of the AlertBox.</param>
 /// <param name="timeout">The time in milliseconds before the AlertBox closes automatically.</param>
 public static void Show(string title, string content, int timeout)
 {
     Close();
     th = new System.Threading.Thread(() =>
     {
         theBox = new AlertBoxForm(title, content, timeout);
         System.Windows.Forms.Application.EnableVisualStyles();
         System.Windows.Forms.Application.Run(theBox);
     });
     th.Start();
 }
Example #2
0
        /// <summary>
        /// Closes the active alert box and stops its UI thread.
        /// </summary>
        public static void Close()
        {
            if (theBox != null)
            {
                if (theBox.InvokeRequired)
                {
                    theBox.Invoke(new Action(() =>
                    {
                        theBox.Close();
                        theBox = null;
                    }));
                }
                else
                {
                    theBox.Close();
                    theBox = null;
                }
            }

            if (th != null ? th.IsAlive : false)
            {
                th.Abort();
            }
        }