We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8bf0c6a commit 7cc89daCopy full SHA for 7cc89da
1 file changed
NitroxServer-Subnautica/Program.cs
@@ -91,13 +91,16 @@ private static void CatchExitEvent()
91
// better catch using WinAPI. This will handled process kill
92
if (platid == PlatformID.Win32NT)
93
{
94
- SetConsoleCtrlHandler(ConsoleEventCallback, true);
+ SetConsoleCtrlHandler(consoleCtrlCheckDelegate, true);
95
}
96
97
98
[DllImport("kernel32.dll", SetLastError = true)]
99
private static extern bool SetConsoleCtrlHandler(ConsoleEventDelegate callback, bool add);
100
101
+ // Prevents Garbage Collection issue where server closes and an exception occurs for this handle.
102
+ private static readonly ConsoleEventDelegate consoleCtrlCheckDelegate = ConsoleEventCallback;
103
+
104
private static bool ConsoleEventCallback(int eventType)
105
106
if (eventType == 2) // close
0 commit comments