/// <summary> /// Removes thread exit callback that has been set with <see cref="SetThreadExitCallback"/>. /// NOTE: callback may be called as a result of this method call on some platforms. /// </summary> /// <param name="callbackId">Callback id returned from <see cref="SetThreadExitCallback"/>.</param> public static void RemoveThreadExitCallback(int callbackId) { if (Os.IsWindows) { var res = NativeMethodsWindows.FlsFree(callbackId); if (!res) { throw new InvalidOperationException("FlsFree failed: " + Marshal.GetLastWin32Error()); } } else if (Os.IsMacOs) { var res = NativeMethodsMacOs.pthread_key_delete(callbackId); NativeMethodsLinux.CheckResult(res); } else if (Os.IsLinux) { var res = Os.IsMono ? NativeMethodsMono.pthread_key_delete(callbackId) : NativeMethodsLinux.pthread_key_delete(callbackId); NativeMethodsLinux.CheckResult(res); } else { throw new InvalidOperationException("Unsupported OS: " + Environment.OSVersion); } }
/// <summary> /// Removes thread exit callback that has been set with <see cref="SetThreadExitCallback"/>. /// </summary> private static void RemoveThreadExitCallbackMono(int callbackId) { CheckResult(NativeMethodsMono.pthread_key_delete(callbackId)); }