I got my solution to work. Changed from the WaveOut class to the WaveOutEvent class, in the WaveOutEvent class the call to the WinMM.Dll waveOutWrite method would throw and exception instead of deadlocking. I ammended the code for WaveOutEvent to catch the MMException being thrown, this catch is in the PlaybackThread method and the handler has the following
catch(MmException ex)
{
buffer = null;
playbackState = PlaybackState.Stopped;
System.Diagnostics.Debug.WrtieLine(ex); // so a debugger can view this is happend and to be able to log using trace listeners.
}
If I did not catch the exception there I would get an unhandled error which is not caught by the application general exception error and my appliation would crash and be unloaded from memory.
Mark