Results 1 to 2 of 2

Thread: Playing a Simultaneous sound as a MsgBox?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2003
    Location
    colorado
    Posts
    17

    Playing a Simultaneous sound as a MsgBox?

    Okay i have when you have this situation that it'll have a msgbox popup and it'll play a sound (say sound.wav) at the same time as the msgbox popups up

    everything i've tried it plays the sound first then shows the msgbox

    is there anyway to play the sound as the msgbox pops up and then stops when you click ok?

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Create a secondary thread that will play the sound before the message box is displayed. When the dialog is closed, kill the thread.

    Code:
    using System;
    using System.Threading;
    using System.Windows.Forms;
    
    public class PlaySound {
        
        static void Main() {
            Thread t = new Thread(new ThreadStart(Play));
            t.Start();
            MessageBox.Show("Crank it up!");
            t.Abort();
        }
    
        static void Play() {
            while (true) {
                Console.WriteLine("Sound Playing...");
                Thread.Sleep(1000);
            }
        }
    }
    Last edited by Lethal; Mar 11th, 2003 at 12:59 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width