ModelViewer.Sound.SoundManager.Dispose C# (CSharp) Method

Dispose() public method

public Dispose ( ) : void
return void
        public void Dispose()
        {
            lock (mutex)
            {
                DisposeWave();

                if (decodeThread != null)
                {
                    decodeThread.Abort();
                    System.Threading.Monitor.Pulse(mutex);
                    decodeThread = null;
                }

                if (streamBuffers != null)
                {
                    foreach (AudioBuffer buffer in streamBuffers)
                    {
                        buffer.AudioData.Dispose();
                        buffer.Dispose();
                    }
                    byteBuffers = null;
                    streamBuffers = null;
                }

                if (masteringVoice != null)
                {
                    masteringVoice.Dispose();
                    masteringVoice = null;
                }

                if (xaudio != null)
                {
                    xaudio.Dispose();
                    xaudio = null;
                }
            }
        }

Usage Example

 public static void Shutdown()
 {
     if (instance != null)
     {
         instance.Dispose();
         instance = null;
     }
 }