From 6410c28594c0c90391da9f39dc885f8529c94115 Mon Sep 17 00:00:00 2001 From: streibeb Date: Fri, 2 Jan 2015 17:49:39 -0600 Subject: [PATCH] Changed web client instances to dispose after use. --- SpotifyAPI/SpoitfyLocalAPI/RemoteHandler.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/SpotifyAPI/SpoitfyLocalAPI/RemoteHandler.cs b/SpotifyAPI/SpoitfyLocalAPI/RemoteHandler.cs index d7973d2c..8ee32ceb 100644 --- a/SpotifyAPI/SpoitfyLocalAPI/RemoteHandler.cs +++ b/SpotifyAPI/SpoitfyLocalAPI/RemoteHandler.cs @@ -137,9 +137,11 @@ namespace SpotifyAPI.SpotifyLocalAPI try { //Need to find a better solution - var wc = new ExtendedWebClientInstance(); - if (SpotifyLocalAPIClass.IsSpotifyRunning()) - response = "[ " + wc.DownloadString(a) + " ]"; + using (var wc = new ExtendedWebClientInstance()) + { + if (SpotifyLocalAPIClass.IsSpotifyRunning()) + response = "[ " + wc.DownloadString(a) + " ]"; + } } catch (Exception z) { @@ -177,9 +179,11 @@ namespace SpotifyAPI.SpotifyLocalAPI try { //Need to find a better solution - var wc = new ExtendedWebClientInstance(); - if (SpotifyLocalAPIClass.IsSpotifyRunning()) - response = "[ " + await wc.DownloadStringTaskAsync(new Uri(a)) + " ]"; + using (var wc = new ExtendedWebClientInstance()) + { + if (SpotifyLocalAPIClass.IsSpotifyRunning()) + response = "[ " + await wc.DownloadStringTaskAsync(new Uri(a)) + " ]"; + } } catch (Exception ex) {