Fix RegistryKey dispose

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
Syrone Wong
2016-10-01 06:53:43 +08:00
parent c46149a375
commit 13ebb5ef01
2 changed files with 20 additions and 10 deletions
@@ -39,8 +39,10 @@ namespace Shadowsocks.Controller
{
if (runKey != null)
{
try { runKey.Close(); }
catch (Exception e)
try {
runKey.Close();
runKey.Dispose();
} catch (Exception e)
{ Logging.LogUsefulException(e); }
}
}
@@ -84,8 +86,10 @@ namespace Shadowsocks.Controller
{
if (runKey != null)
{
try { runKey.Close(); }
catch (Exception e)
try {
runKey.Close();
runKey.Dispose();
} catch (Exception e)
{ Logging.LogUsefulException(e); }
}
}
@@ -84,8 +84,10 @@ namespace Shadowsocks.Controller
MessageBox.Show( I18N.GetString( "Failed to update registry" ) );
} finally {
if ( registry != null ) {
try { registry.Close(); }
catch (Exception e)
try {
registry.Close();
registry.Dispose();
} catch (Exception e)
{ Logging.LogUsefulException(e); }
}
}
@@ -119,8 +121,10 @@ namespace Shadowsocks.Controller
Logging.LogUsefulException( e );
} finally {
if ( registry != null ) {
try { registry.Close(); }
catch (Exception e)
try {
registry.Close();
registry.Dispose();
} catch (Exception e)
{ Logging.LogUsefulException(e); }
}
}
@@ -165,8 +169,10 @@ namespace Shadowsocks.Controller
} finally {
if (registry != null)
{
try { registry.Close(); }
catch (Exception e)
try {
registry.Close();
registry.Dispose();
} catch (Exception e)
{ Logging.LogUsefulException(e); }
}
}