Skip to content

Commit 7cc89da

Browse files
authored
Reverted removal of a fix and added a comment (SubnauticaNitrox#1069)
1 parent 8bf0c6a commit 7cc89da

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

NitroxServer-Subnautica/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,16 @@ private static void CatchExitEvent()
9191
// better catch using WinAPI. This will handled process kill
9292
if (platid == PlatformID.Win32NT)
9393
{
94-
SetConsoleCtrlHandler(ConsoleEventCallback, true);
94+
SetConsoleCtrlHandler(consoleCtrlCheckDelegate, true);
9595
}
9696
}
9797

9898
[DllImport("kernel32.dll", SetLastError = true)]
9999
private static extern bool SetConsoleCtrlHandler(ConsoleEventDelegate callback, bool add);
100100

101+
// Prevents Garbage Collection issue where server closes and an exception occurs for this handle.
102+
private static readonly ConsoleEventDelegate consoleCtrlCheckDelegate = ConsoleEventCallback;
103+
101104
private static bool ConsoleEventCallback(int eventType)
102105
{
103106
if (eventType == 2) // close

0 commit comments

Comments
 (0)