The first form you open has a special meaning - it's the mainwindow.
When you close that window the application closes.
In my windows forms application this is Form2.
I handle the FormClosing event on that window and it works OK for me:
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"C:\Windows\Media\Alarm09.wav");
player.Play();
Application.DoEvents();
System.Threading.Thread.Sleep(1000);
}
Hope that helps
Please don't forget to up vote answers you like or which help you and mark one(s) which answer your question.
No comments:
Post a Comment