Description
The Dispose
method is used to release all resources used by the SoundHandle
instance. This method is crucial for managing memory and ensuring that resources are properly cleaned up when the sound is no longer needed. Once a SoundHandle
is disposed, it should not be used again.
This method is sealed, meaning it cannot be overridden in derived classes. It is also virtual, allowing for potential extension in future versions of the API, but currently, it is implemented as a final method.
Usage
Call Dispose
when you are finished with a SoundHandle
to free up resources. This is especially important in environments with limited resources or when dealing with a large number of sounds.
After calling Dispose
, the SoundHandle
should not be used, as it will no longer be valid.
Example
// Example of using Dispose on a SoundHandle
SoundHandle sound = new SoundHandle();
// Play the sound or perform operations
// Once done, dispose of the sound handle
sound.Dispose();
// After disposing, the sound handle should not be used
// sound.Stop(); // This would be invalid after Dispose