AutomationDrivers.IisExpressHost.IisExpress.SendStopMessageToProcess C# (CSharp) Method

SendStopMessageToProcess() private static method

Sends a stop message to process.
private static SendStopMessageToProcess ( int pid ) : void
pid int The process ID assigned to the current IISEcpress instance.
return void
        private static void SendStopMessageToProcess(int pid)
        {
            try
            {
                for (var ptr = NativeMethods.GetTopWindow(IntPtr.Zero); ptr != IntPtr.Zero; ptr = NativeMethods.GetWindow(ptr, 2))
                {
                    uint num;
                    NativeMethods.GetWindowThreadProcessId(ptr, out num);
                    if (pid == num)
                    {
                        var hWnd = new HandleRef(null, ptr);
                        NativeMethods.PostMessage(hWnd, 0x12, IntPtr.Zero, IntPtr.Zero);
                        return;
                    }
                }
            }
            catch (ArgumentException)
            {
            }
        }