0XC0010002

Fix DBG_APP_NOT_IDLE (0XC0010002) in Visual Studio

Programming & Dev Tools Intermediate 👁 29 views 📅 Jun 14, 2026

Visual Studio debugger throws this when your app isn't idle. You're likely hitting a breakpoint during startup or in a tight loop.

Quick answer

Move your breakpoint to a line that executes after the application enters its main message loop or idle state — usually after Application.Run() in WinForms or after app.Run() in WPF.

Why this happens

This error pops up when you're debugging a Windows desktop app (WinForms, WPF, or even a console app with a message pump) and you set a breakpoint on code that runs before the application has a chance to go idle. The Visual Studio debugger expects the app to hit an idle state — where it's waiting for user input or system messages — before it can safely inject breakpoints or evaluate expressions. If you break too early, the debugger throws 0XC0010002.

I've seen this most often when someone puts a breakpoint in a form constructor or in the Main() method before Application.Run(). For example, in a WinForms app, if you break inside Form1_Load, the form hasn't fully initialized its message pump yet. The debugger literally tells you: "I can't work until you let the app sit idle."

Another common trigger is a tight loop that never yields — like a while(true) that doesn't pump messages. The debugger can't detect idle because the CPU is pinned.

Step-by-step fix

  1. Check where your breakpoint is. Open the breakpoints window (Ctrl+Alt+B in Visual Studio). Look at the file and line number. If it's in a constructor, the Load event, or any method called before Application.Run(), that's your problem.
  2. Move the breakpoint to later code. For a WinForms app, set it on a button click handler, a timer tick, or after Application.Run() if you're in a console app. For WPF, set it on a Loaded event (not the constructor). After you apply this change, restart the debug session (F5). You should see the breakpoint hit normally now.
  3. If you need to debug startup code, use System.Diagnostics.Debugger.Launch() or System.Diagnostics.Debugger.Break() after the idle state. For instance, put Debugger.Break() inside a Shown event in WinForms — that fires after the form is visible and idle.
  4. Still stuck? Try disabling "Enable Just My Code" in Tools > Options > Debugging > General. It's not a silver bullet, but I've seen it force the debugger to handle early breaks more gracefully. Re-run after toggling it.
  5. If nothing works, add a Sleep call: Thread.Sleep(100); right before your breakpoint line. This gives the debugger time to detect idle. Hacky but works in a pinch.

Alternative fixes

For WinForms specifically: Don't break in Form1_Load. Use Form1_Shown instead — that fires after the form is displayed and idle. Here's the pattern:

private void Form1_Shown(object sender, EventArgs e)
{
// Your debug code here, like Debugger.Break();
}

For WPF: Use the ContentRendered event instead of Loaded:

this.ContentRendered += (s, e) =>
{
System.Diagnostics.Debugger.Break();
};

For console apps with a message pump (like using System.Windows.Forms.Application.Run() in a console app), set the breakpoint on the line after the Run() call. But honestly, that pattern is rare — you're usually better off using Task.Delay or a manual message loop if you need idle detection.

Prevention tip

The easiest way to avoid 0XC0010002 is to never set breakpoints in constructors, Load events, or any code that runs before the UI framework has started pumping messages. I always set a breakpoint on the first interactive step — like a button click — and work backward if I need to trace startup. That saves you the headache of this error and keeps the debugger happy.

Also, if you're using while(true) loops without Application.DoEvents() or await Task.Yield(), the app will never go idle. Add a yield or a short sleep to let the debugger do its job.

Was this solution helpful?