Why does my program successfully take foreground only when running under the debugger? That’s a special exception to the normal foreground rules. Click here to read the article