How to use a thread in a playback function
<p>I want to playback a sound file in two or three external sound cards at the same time and I think that using threads is the solution but I really didn't know how to use it in the playback code.
This is the event makes on button play:</p>

<pre><code>public partial class PlaybackForm : Form
{
    IWavePlayer waveOut;
    string fileName = null;
    WaveStream mainOutputStream;
    WaveChannel32 volumeStream;
    int _deviceNum;
    int _deviceNum1;
    Thread t1;
    Thread t2;
    public PlaybackForm(int deviceNum,int deviceNum1)
    {
        InitializeComponent();
        _deviceNum = deviceNum;
        _deviceNum1 = deviceNum1;
    }


    private void buttonPlay_Click(object sender, EventArgs e)
    {
        if (waveOut != null)
        {
            if (waveOut.PlaybackState == PlaybackState.Playing)
            {
              return;
            }
            else if (waveOut.PlaybackState == PlaybackState.Paused)
            {
                waveOut.Play();
                return;
            }
        }

        // we are in a stopped state
        // TODO: only re-initialise if necessary

        if (String.IsNullOrEmpty(fileName))
        {
            toolStripButtonOpenFile_Click(sender, e);
        }
        if (String.IsNullOrEmpty(fileName))
        {
            return;
        }

        try
        {
            CreateWaveOut();
        }
        catch (Exception driverCreateException)
        {
            MessageBox.Show(String.Format("{0}", driverCreateException.Message));
            return;
        }

        mainOutputStream = CreateInputStream(fileName);
        trackBarPosition.Maximum = (int)mainOutputStream.TotalTime.TotalSeconds;
        labelTotalTime.Text = String.Format("{0:00}:{1:00}", (int)mainOutputStream.TotalTime.TotalMinutes,
            mainOutputStream.TotalTime.Seconds);
        trackBarPosition.TickFrequency = trackBarPosition.Maximum / 30;

        try
        {
            waveOut.Init(mainOutputStream);
        }
        catch (Exception initException)
        {
            MessageBox.Show(String.Format("{0}", initException.Message), "Error Initializing Output");
            return;
        }

        // not doing Volume on IWavePlayer any more
        volumeStream.Volume = volumeSlider1.Volume;
        waveOut.Play();
    }
</code></pre>

<p>And this is how to create the waveout:</p>

<pre><code>  private void CreateWaveOut()
    {
        CloseWaveOut();
        int latency = (int)comboBoxLatency.SelectedItem;
        //if (radioButtonWaveOut.Checked)
        {
            //WaveCallbackInfo callbackInfo = checkBoxWaveOutWindow.Checked ?
            WaveCallbackInfo callbackInfo = WaveCallbackInfo.FunctionCallback();
            // WaveCallbackInfo callbackInfo = WaveCallbackInfo.FunctionCallback();

            // WaveCallbackInfo.NewWindow(): WaveCallbackInfo.FunctionCallback();
            WaveOut outputDevice = new WaveOut(callbackInfo);
            outputDevice.DesiredLatency = latency;
            outputDevice.DeviceNumber = _deviceNum;
            waveOut = outputDevice;
        }

    }
</code></pre>

<p>I declared two deviceNum but until now I can playsound only in one device,that's why I want to use thread.
Can you help me please
Thank you in advance</p>
