diff --git a/SoundSwitch/Model/CachedAudioDeviceLister.cs b/SoundSwitch/Model/CachedAudioDeviceLister.cs
index 7e502a43b1..41adc0e879 100644
--- a/SoundSwitch/Model/CachedAudioDeviceLister.cs
+++ b/SoundSwitch/Model/CachedAudioDeviceLister.cs
@@ -25,9 +25,9 @@ namespace SoundSwitch.Model
{
public class CachedAudioDeviceLister : IAudioDeviceLister
{
-
///
public ICollection PlaybackDevices { get; private set; }
+
///
public ICollection RecordingDevices { get; private set; }
@@ -47,35 +47,22 @@ private void DeviceChanged(object sender, DeviceChangedEventBase e)
private void Refresh()
{
- if (!Monitor.TryEnter(this, 500))
+ var playbackTask = Task>.Factory.StartNew((() =>
{
- return;
- }
- try
- {
-
- var playbackTask = Task>.Factory.StartNew((() =>
+ using (var enumerator = new MMDeviceEnumerator())
{
- using (var enumerator = new MMDeviceEnumerator())
- {
- return CreateDeviceList(enumerator.EnumerateAudioEndPoints(DataFlow.Render, _state));
- }
- }));
- var recordingTask = Task>.Factory.StartNew((() =>
- {
- using (var enumerator = new MMDeviceEnumerator())
- {
- return CreateDeviceList(enumerator.EnumerateAudioEndPoints(DataFlow.Capture, _state));
- }
- }));
- PlaybackDevices = playbackTask.Result;
- RecordingDevices = recordingTask.Result;
- }
- finally
+ return CreateDeviceList(enumerator.EnumerateAudioEndPoints(DataFlow.Render, _state));
+ }
+ }));
+ var recordingTask = Task>.Factory.StartNew((() =>
{
- Monitor.Exit(this);
- }
-
+ using (var enumerator = new MMDeviceEnumerator())
+ {
+ return CreateDeviceList(enumerator.EnumerateAudioEndPoints(DataFlow.Capture, _state));
+ }
+ }));
+ PlaybackDevices = playbackTask.Result;
+ RecordingDevices = recordingTask.Result;
}
private static ICollection CreateDeviceList(MMDeviceCollection collection)
@@ -90,13 +77,13 @@ private static ICollection CreateDeviceList(MMDeviceCollection c
{
continue;
}
+
sortedDevices.Add(device.FriendlyName, deviceInfo);
}
catch (Exception)
{
Log.Warning("Can't get name of device {device}", device.ID);
}
-
}
return sortedDevices.Values;