I am playing sounds with System.Media.SoundPlayer
. Unfortunately the C# application tends to hang forever if the underlying sound device is removed during the play.
I could detect the removal of the device and stop the playback. But this seems to be (already) too late.
There is no exception or so, any chance to avoid the "crash" of the C# application?
As Jimi pointed out, running the
SoundPlayer
in aTask
helps. Credits to him.