private static void Initialize() { if (windowHook != IntPtr.Zero) { throw new NotSupportedException("Multiple calls are not supported."); } if (ownerPtr != null) { // Note, while AppDomain.GetCurrentThreadId() is deprecated, the suggested replacement is not valid, thus we will continue to use this windowHook = CenteredDialogBox.SetWindowsHookEx(WH_CALLWNDPROCRET, hookProc, IntPtr.Zero, AppDomain.GetCurrentThreadId()); } }
private static void Initialize() { if (windowHook != IntPtr.Zero) { throw new NotSupportedException("Multiple calls are not supported."); } if (ownerPtr != null) { ProcessThread processThread = Process.GetCurrentProcess().Threads .OfType <ProcessThread>() .FirstOrDefault(thread => thread.ThreadState == ThreadState.Running); if (processThread != null) { windowHook = CenteredDialogBox.SetWindowsHookEx(WH_CALLWNDPROCRET, hookProc, IntPtr.Zero, processThread.Id); } } }