protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _playingItem.Dispose(); } _disposed = true; }
/// <summary> /// Проиграть 1 звуковой элемент (1 файл). /// </summary> public async Task <bool> PlayFile(SoundItem soundItem, CancellationToken cts) { SetVolume(0.9f); var item = new SoundItem4NAudio(soundItem); try { _playingItem = item; await PlaySoundItem(item, cts); //При сработке cts, генерируется исключение и мы попадаем в блок finally. _playingItem = null; } finally { item.Dispose(); } return(true); }