refactor: use using for SoundPlayer
This commit is contained in:
parent
0b54dc4271
commit
172bfa6025
@ -464,14 +464,14 @@ namespace PeepingTom {
|
||||
} else {
|
||||
player = new SoundPlayer(this.config.SoundPath);
|
||||
}
|
||||
try {
|
||||
player.Play();
|
||||
} catch (FileNotFoundException e) {
|
||||
this.SendError($"Could not play sound: {e.Message}");
|
||||
} catch (InvalidOperationException e) {
|
||||
this.SendError($"Could not play sound: {e.Message}");
|
||||
} finally {
|
||||
player.Dispose();
|
||||
using (player) {
|
||||
try {
|
||||
player.Play();
|
||||
} catch (FileNotFoundException e) {
|
||||
this.SendError($"Could not play sound: {e.Message}");
|
||||
} catch (InvalidOperationException e) {
|
||||
this.SendError($"Could not play sound: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user