I am coding Windows Forms in C# under Visual Studio 2012 and I would like to open multiple instances of MessageBox and automatically close them after several seconds.
I have found (and upvoted) this answer here: SO: Close a MessageBox after several seconds.
However, this works if I only open 1 (one) MessageBox at a time, since it makes use of the function FindWindow
, and the multiple instances of my MessageBox shall have all the same window title (caption).
[Optionally] In addition, I would like to present the user with a countdown, like This dialog will close in 5 seconds, This [...] in 4 seconds, This [...] in 3 seconds, ..., This [...] in 1 seconds and then finally close the MessageBox.
Is there a way to uniquely reference my multiple MessageBoxes and automatically close them (either using System.Timers.Timer
or System.Threading.Timer
or System.Windows.Forms.Timer
- whichever is the best fit for this solution) after a certain period of time (say 5 seconds)?