Merge fixes from @GangZhuo, close #478 (#638)

Squashed commit of the following:

commit e280c2385c
Merge: 579039f 87aa9eb
Author: Gang Zhuo <gang.zhuo@gmail.com>
Date:   Wed Mar 16 04:02:27 2016 -0400

    Merge remote-tracking branch 'origin/master'

commit 579039fe40
Author: Gang Zhuo <gang.zhuo@gmail.com>
Date:   Fri Mar 4 21:45:23 2016 +0800

    log unhandle exception

commit 8d863f1d5f
Author: Gang Zhuo <gang.zhuo@gmail.com>
Date:   Fri Mar 4 21:44:54 2016 +0800

    fix Availability Statistics

commit b3ce1c698a
Author: Gang Zhuo <gang.zhuo@gmail.com>
Date:   Fri Mar 4 21:07:54 2016 +0800

    tiny refactor

commit 0f7d39e27e
Merge: bd7078a b01aced
Author: Gang Zhuo <gang.zhuo@gmail.com>
Date:   Fri Mar 4 20:02:58 2016 +0800

    Merge remote-tracking branch 'origin/master'

commit bd7078aa4f
Author: Gang Zhuo <gang.zhuo@gmail.com>
Date:   Fri Mar 4 20:01:58 2016 +0800

    tiny refactor

commit 49adb95b6e
Author: Gang Zhuo <gang.zhuo@gmail.com>
Date:   Fri Mar 4 03:44:26 2016 -0500

    log more Ping information for debug

commit 2aa0620ddd
Author: Gang Zhuo <gang.zhuo@gmail.com>
Date:   Fri Mar 4 03:04:10 2016 -0500

    reduce 3rd packages

[solve conflicts and squash to make history clean]
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
Syrone Wong
2016-08-05 11:05:16 +08:00
committed by GitHub
parent b0f71c43f5
commit 6a8a09983e
9 changed files with 265 additions and 219 deletions
+15
View File
@@ -21,6 +21,7 @@ namespace Shadowsocks
Utils.ReleaseMemory(true);
using (Mutex mutex = new Mutex(false, "Global\\Shadowsocks_" + Application.StartupPath.GetHashCode()))
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
@@ -53,5 +54,19 @@ namespace Shadowsocks
Application.Run();
}
}
private static int exited = 0;
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (Interlocked.Increment(ref exited) == 1)
{
Logging.Error(e.ExceptionObject?.ToString());
MessageBox.Show(I18N.GetString("Unexpect error, shadowsocks will be exit. Please report to") +
" https://github.com/shadowsocks/shadowsocks-windows/issues " +
Environment.NewLine + (e.ExceptionObject?.ToString()),
"Shadowsocks Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
}
}
}