From 6a37539b37f039362fa96c53a12f4749487e932c Mon Sep 17 00:00:00 2001 From: Pariring Date: Wed, 9 Nov 2022 17:11:51 +0900 Subject: [PATCH] feat: catch exception for error in thread --- Runtime/SkyHookManager.cs | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Runtime/SkyHookManager.cs b/Runtime/SkyHookManager.cs index 73b6a18..85a1d59 100644 --- a/Runtime/SkyHookManager.cs +++ b/Runtime/SkyHookManager.cs @@ -79,20 +79,28 @@ namespace SkyHook new Thread(() => { - if (isHookActive) return; - - var result = SkyHookNative.StartHook(HookCallback); - - if (result != null) + try { - exception = new SkyHookException(result); + if (isHookActive) return; + + var result = SkyHookNative.StartHook(HookCallback); + + if (result != null) + { + exception = new SkyHookException(result); + } + + isHookActive = true; + started = true; + + while (isHookActive) + { + } } - - isHookActive = true; - started = true; - - while (isHookActive) + catch (Exception e) { + exception = e; + throw; } }).Start();