feliwir / feliwir/SharpAudio

Null Reference Exception after disposing and re-initializing object

Ouverte
#21 6 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C#
Étoiles
194
Forks
20
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

```
if (!String.IsNullOrEmpty(_nextSongToPlay))
{
if (activeMusic!=null && activeMusic.State== SoundStreamState.Playing)
{
activeMusic.Stop();
activeMusic.Dispose();
}
activeMusic = new SoundStream(System.IO.File.OpenRead(_nextSongToPlay), musicEngine);
System.Threading.Thread.Sleep(100);
activeMusic.Volume = currentVolume;
activeMusic.Play();
_nextSongToPlay = null;
}
```

It seems that there is some kind of race condition that is triggered by calling the activeMusic.Stop(); method... without putting a System.Threading.Thread.Sleep setting the volume on the activeMusic soundstream causes a null exception to be thrown.

This exception occurs if the activeMusic soundstream is or is not disposed, but only if it was not null before creating the New soundStream

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.