Hi! I don't speak english good, sorry but I speak spanish.
This is my code, that have a problem. Sometime, it finalize the application with an error (the application stopped working).
The code:
var t = new Thread(() =>
{
try
{
sonido.Position = 0; // Reset position... sonido = Properties.Resources.bateria_1
var StreamFile = new WaveFileReader(sonido);
var time = StreamFile.TotalTime.Milliseconds + 2200; // the sum is for prevent an error
var Channel32 = new WaveChannel32(StreamFile);
var waveout = new WaveOut(WaveCallbackInfo.FunctionCallback());
waveout.Init(Channel32);
waveout.Play();
Thread.Sleep(time);
waveout.Stop();
waveout.Dispose();
Thread.CurrentThread.Abort();
}
catch(IOException e) {
MessageBox.Show("Error: " + e.Message); // this exception e, dont have a description for view the error...
}
});
t.Name = "Sonido_platillo";
t.Start();
Thanks!
This is my code, that have a problem. Sometime, it finalize the application with an error (the application stopped working).
The code:
var t = new Thread(() =>
{
try
{
sonido.Position = 0; // Reset position... sonido = Properties.Resources.bateria_1
var StreamFile = new WaveFileReader(sonido);
var time = StreamFile.TotalTime.Milliseconds + 2200; // the sum is for prevent an error
var Channel32 = new WaveChannel32(StreamFile);
var waveout = new WaveOut(WaveCallbackInfo.FunctionCallback());
waveout.Init(Channel32);
waveout.Play();
Thread.Sleep(time);
waveout.Stop();
waveout.Dispose();
Thread.CurrentThread.Abort();
}
catch(IOException e) {
MessageBox.Show("Error: " + e.Message); // this exception e, dont have a description for view the error...
}
});
t.Name = "Sonido_platillo";
t.Start();
Thanks!