ERROR_THREAD_NOT_IN_PROCESS (566): Causes and Fixes

TutorialPedia Team

Date Updated

If you have just seen a dialog, a log entry, or an API failure report ERROR_THREAD_NOT_IN_PROCESS — also shown as error code 566, hex 0x236, or HRESULT 0x80070236 — you are dealing with a Windows system error that points to a mismatch between a thread and the process it is supposed to belong to. It can pop up while an application is running or while Windows is starting, and it is confusing precisely because the message is written for programmers, not for the person trying to finish their work.

This guide explains what the error thread not in process message actually means, where it comes from, and how to get rid of it. You will find step-by-step fixes for Windows 11 and Windows 10, plus a developer section that shows how to decode the code and prevent it in your own software.

Table of Contents#

  1. What ERROR_THREAD_NOT_IN_PROCESS Means
  2. Where the Error Shows Up
  3. What Causes the Error
  4. Quick Checks Before You Dig In
  5. Fix 1: Repair System Files with DISM and SFC
  6. Fix 2: Isolate Conflicting Software with a Clean Boot
  7. Fix 3: Scan for Malware
  8. Fix 4: Update Windows and Device Drivers
  9. Fix 5: Check Your Disk and Memory
  10. Fix 6: Roll Back Changes with System Restore
  11. Fix 7: Startup Repair and Reset This PC
  12. Developer Guide: Handling the Error in Code
  13. Best Practices and Common Mistakes
  14. FAQ
  15. Conclusion
  16. References

What ERROR_THREAD_NOT_IN_PROCESS Means#

Windows defines this condition in its standard system error code list (WinError.h). The official definition is:

PropertyValue
Symbolic nameERROR_THREAD_NOT_IN_PROCESS
Decimal code566
Hex (Win32)0x236
HRESULT form0x80070236 (via HRESULT_FROM_WIN32)
NTSTATUS counterpartSTATUS_THREAD_NOT_IN_PROCESS (0xC000012A)
Message"An attempt was made to operate on a thread within a specific process, but the thread specified is not in the process specified."

In plain English: some software asked Windows to act on a specific thread inside a specific process, and the thread ID (or handle) it passed does not belong to that process. The thread may live in a different process, may have already exited, or the caller may simply have passed the wrong identifier.

Because Win32 error codes are 16-bit values reused across different surfaces, the same problem can appear in several disguises:

  • GetLastError() returning 566 or 0x236 in an application or debugger
  • An HRESULT of 0x80070236 in a crash report, COM log, or PowerShell output
  • An NTSTATUS of 0xC000012A in a kernel-mode or driver trace
  • A plain-language dialog such as "An attempt was made to operate on a thread within a specific process…" from an app that formats the message for you

All four describe the same underlying condition.

Where the Error Shows Up#

Knowing where the code surfaces tells you which layer to fix:

  1. Application error dialogs and program logs. Desktop apps, games, installers, and background services that manage threads themselves (for example tools that inject code, capture performance data, or inspect other processes) can surface the message when one of their thread operations fails.
  2. Windows Error Reporting and Event Viewer. When an app crashes, Windows records the details in the Application log. Error-level Event ID 1000 entries (source "Application Error") name the faulting application and module, while Event ID 1001 entries reflect the related Windows Error Reporting information.
  3. Developer tooling. Debuggers, profilers, and test harnesses see the raw code from GetLastError(), and WinDbg can decode it instantly (see the developer section below).
  4. Startup or shutdown paths. If the error appears while booting, it usually comes from a startup item, service, or driver rather than from Windows itself — which is why isolating startup software is one of the most effective fixes.

What Causes the Error#

The code is a symptom, not a root cause. These are the situations that reliably produce it:

  • A thread that no longer exists. Threads are short-lived by nature. If a program looks up a thread, the thread exits, and the program then operates on the stale ID, the thread may no longer be in the process — or the ID may have been reused for a thread in another process.
  • Cross-process confusion. Passing a thread from process A together with a handle to process B triggers the exact condition the message describes. This is a classic bug in tools that work across process boundaries: debuggers, overlays, anti-cheat software, accessibility tools, and security products.
  • Corrupted system files. Damaged Windows components can make otherwise healthy applications fail in unexpected ways, including thread and process management errors. Microsoft's repair documentation lists "system errors" among the symptoms of missing or corrupted system files.
  • Conflicting background software. Services, startup apps, overlays, and utilities that inject into other processes are a common source of interference — the reason Microsoft recommends a clean boot to identify "background software conflicts affecting apps or games".
  • Malware. Malicious code frequently manipulates threads and processes in other programs. When that manipulation goes wrong, the target application reports low-level errors like this one.
  • Outdated or faulty drivers and missing updates. Kernel components participate in every thread operation, so a stale or broken driver can surface as an odd process/thread error in user-mode applications.
  • Failing hardware. Memory or storage problems corrupt data structures that describe threads and processes. This is less common, but worth ruling out if the error appears across many different applications.

Quick Checks Before You Dig In#

Before running any repair tool, gather facts. Five minutes here can save hours later.

  1. Note exactly which program shows the error. A code is only actionable when you know what produced it. If the dialog does not name the app, check Event Viewer: open it, go to Windows Logs > Application, and look for Error-level events around the time of the failure. Event ID 1000 entries list the faulting application and module.
  2. Restart Windows. Thread bookkeeping errors are often transient races that disappear after a reboot.
  3. Install pending updates. Go to Settings > Windows Update and install everything offered, including optional driver updates. If updates will not install, run the Windows Update troubleshooter (Settings > System > Troubleshoot > Other troubleshooters > Windows Update).
  4. Reproduce the problem. Try to trigger the error again and note the steps. A reproducible case tells you whether the fault follows one app (an application bug) or many apps (a system problem).
  5. Check whether the problem is new. If it started after installing something — a driver, a game overlay, an antivirus, a system utility — that installation is your prime suspect.

Fix 1: Repair System Files with DISM and SFC#

Windows ships two built-in repair tools, and Microsoft's documented order matters: run DISM first so the component store is healthy, then run System File Checker so it has good files to copy from.

  1. Open an elevated Command Prompt: search for cmd, right-click Command Prompt, and select Run as administrator.

  2. Run DISM. It can take several minutes:

    DISM.exe /Online /Cleanup-Image /RestoreHealth

    If Windows Update itself is broken and DISM cannot download repair files, point it at a known-good source instead:

    DISM.exe /Online /Cleanup-Image /RestoreHealth /Source:C:\RepairSource\Windows /LimitAccess
  3. Run System File Checker and let it reach 100% before closing the window:

    sfc /scannow
  4. Reboot and test.

Interpret the SFC result:

  • "did not find any integrity violations" — system files are intact; move on to the next fix.

  • "found corrupt files and successfully repaired them" — retry the task that showed the error.

  • "found corrupt files but was unable to fix some of them" — export the details and replace the named files manually:

    findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log >"%userprofile%\Desktop\sfcdetails.txt"
  • "could not perform the requested operation" — rerun sfc /scannow in Safe Mode (see Fix 7 for how to reach startup settings).

Fix 2: Isolate Conflicting Software with a Clean Boot#

Killing random tasks in Task Manager rarely finds the real conflict. A clean boot is Microsoft's supported method: Windows starts with only essential Microsoft services and no third-party startup apps, so you can prove whether background software is involved.

  1. Sign in as an administrator, press Win + R, type msconfig, and press Enter.
  2. On the Services tab, select Hide all Microsoft services, then Disable all, then Apply.
  3. On the Startup tab, select Open Task Manager and disable every enabled startup item. Screenshot the list first — you will need it to restore your setup.
  4. Return to System Configuration, select OK, and restart.
  5. Retry the operation that failed.

If the error disappears in the clean boot, re-enable services and startup items in batches (half at a time, restarting between rounds) until you identify the offender. Typical culprits are overlays, RGB/peripheral suites, game boosters, older antivirus tools, and anything that injects into other processes. Then update or uninstall that software. When you are finished, restore normal startup by re-enabling the items you disabled.

Also uninstall anything installed shortly before the problem started: open Settings > Apps > Installed apps (or appwiz.cpl), sort by install date, and remove the suspects.

Fix 3: Scan for Malware#

Malware that manipulates threads in other processes can make those processes fail with exactly this kind of error. Windows Security offers several scan types:

  1. Open Windows Security > Virus & threat protection > Scan options.
  2. Run a Full scan. It checks every file and program on the device and takes considerably longer than a quick scan.
  3. If you still suspect infection, run Microsoft Defender Antivirus (offline scan). It restarts the device and scans before Windows loads, which makes it much harder for persistent malware to hide or defend itself. Results appear under Protection history after the PC restarts.

If you use a third-party antivirus product, run its deep-scan equivalent as well.

Fix 4: Update Windows and Device Drivers#

Thread and process operations rely on kernel components, so current Windows builds and drivers matter.

  1. Windows: Settings > Windows Update > Check for updates. Install cumulative updates and restart when prompted.
  2. Update failures: run the Windows Update troubleshooter, then retry. If the component store is damaged, combine this with the DISM step from Fix 1.
  3. Drivers: Windows 11 installs recommended drivers through Windows Update and exposes additional ones as optional updates. Open Settings > Windows Update > Advanced options > Optional updates and install available driver updates. You can also update a specific device through Device Manager > right-click the device > Update driver.
  4. Recently updated drivers: if the error started right after a driver update, roll that device back (Device Manager > Properties > Driver > Roll Back Driver) or uninstall the device and let Windows reinstall it on the next boot.

Fix 5: Check Your Disk and Memory#

Damaged storage and failing memory corrupt the very data structures that describe processes and threads. Rule them out with the built-in tools.

File system integrity:

chkdsk /scan

The /scan switch runs an online scan on NTFS volumes. If it reports problems, schedule a repair with chkdsk /f C: and reboot so Windows can fix the volume.

Memory: run the Windows Memory Diagnostic tool. Press Win + R, type mdsched.exe, choose to restart now, and let the test complete. If it reports hardware errors, test or replace the affected RAM module — no amount of software repair will fix a failing memory stick.

Fix 6: Roll Back Changes with System Restore#

If the error is recent and you know a change preceded it, System Restore can revert system files, drivers, and registry settings without touching your personal documents.

  1. Search for Create a restore point and open the System Properties dialog.
  2. Select System Restore, then Choose a different restore point if offered.
  3. Pick a restore point dated before the problem began and follow the wizard to completion.
  4. After the restore, reinstall any apps or updates that were added after that date (their changes are undone).

If the error persists, the trigger predates the restore point — move on to the next fix.

Fix 7: Startup Repair and Reset This PC#

When the error blocks startup or nothing above helps, work through the recovery ladder in the Windows Recovery Environment (WinRE). Reach it by letting the device fail to boot a few times, or via Settings > System > Recovery > Advanced startup > Restart now.

  1. Startup Repair: in WinRE, select Troubleshoot > Advanced options > Startup Repair. It automatically fixes common boot problems, including missing or damaged system files and boot configuration issues.
  2. Safe Mode: use Troubleshoot > Advanced options > Startup Settings > Restart, then press F4 (or F5 for Safe Mode with networking). If the error disappears in Safe Mode, it is caused by third-party software or drivers — return to Fix 2.
  3. Reset this PC: as a last resort, Settings > System > Recovery > Reset PC. Choose whether to keep your files, and note that installed desktop applications must be reinstalled afterward.

Developer Guide: Handling the Error in Code#

If you are seeing 566 from GetLastError(), the error is telling you something specific: the thread you named is not in the process you named. Here is how to confirm it, decode it, and avoid it.

Decode the code on any surface#

In WinDbg or the Windows debugging tools, !error prints the message directly:

0:000> !error 566
0:000> !error 0xc000012a 1

(The flag 1 tells !error to read the value as an NTSTATUS code.)

In your own code, use FormatMessage with FORMAT_MESSAGE_FROM_SYSTEM to turn any system error code into text:

#include <windows.h>
#include <stdio.h>
 
void PrintWin32Error(DWORD code)
{
    LPWSTR text = NULL;
    DWORD len = FormatMessageW(
        FORMAT_MESSAGE_ALLOCATE_BUFFER |
        FORMAT_MESSAGE_FROM_SYSTEM |
        FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL,
        code,
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
        (LPWSTR)&text,
        0,
        NULL);
 
    if (len > 0) {
        wprintf(L"%lu (0x%lX): %ls\n", code, code, text);
        LocalFree(text);
    }
}
 
// After a failed thread API call:
// PrintWin32Error(GetLastError());  // 566 (0x236): An attempt was made ...

In PowerShell, the same lookup is a one-liner:

[System.ComponentModel.Win32Exception]::new(566).Message

Remember the disguises: HRESULT_FROM_WIN32(566) evaluates to 0x80070236, and the kernel-mode equivalent is STATUS_THREAD_NOT_IN_PROCESS (0xC000012A). If your logs show any of these three, you are looking at the same condition.

Verify the thread actually belongs to the process#

Before operating on a thread in a known process, confirm the relationship with the Tool Help snapshot API:

#include <windows.h>
#include <tlhelp32.h>
 
BOOL ThreadBelongsToProcess(DWORD tid, DWORD pid)
{
    BOOL belongs = FALSE;
    HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
    if (snap == INVALID_HANDLE_VALUE)
        return FALSE;
 
    THREADENTRY32 te;
    te.dwSize = sizeof(te);
 
    if (Thread32First(snap, &te)) {
        do {
            if (te.th32ThreadID == tid) {
                belongs = (te.th32OwnerProcessID == pid);
                break;
            }
        } while (Thread32Next(snap, &te));
    }
 
    CloseHandle(snap);
    return belongs;
}

Design rules that prevent the error#

  • Prefer handles over raw IDs. A thread ID can be recycled after a thread exits, so an ID alone can silently point at a different thread later. Open the thread once (OpenThread), keep the handle for the duration of the work, and close it when done.
  • Expect threads to disappear. Treat ERROR_THREAD_NOT_IN_PROCESS (and related thread-lifetime failures) as a normal, recoverable outcome, not a fatal bug. Log it, clean up, and continue.
  • Minimize cross-process operations. Every operation that pairs a thread from one process with another process is an opportunity for this mismatch. Re-check ownership immediately before the operation and hold the process handle you validated against.
  • Handle races explicitly. Between "enumerate threads" and "use thread", the thread can terminate. Do the verification and the operation as close together as possible, and handle the failure path gracefully.

Best Practices and Common Mistakes#

  • Do not skip DISM. Running sfc /scannow before DISM /Online /Cleanup-Image /RestoreHealth can fail simply because the repair source is itself damaged.
  • Do not confuse closing apps with diagnosing conflicts. Ending visible tasks in Task Manager does not stop services or startup items. Use a clean boot when you need real evidence.
  • Do not trust unsigned "repair" utilities. Downloading random tools that promise to fix system error codes often makes the problem worse. Everything in this guide uses Windows built-ins.
  • Do not ignore which app is faulting. Fixing Windows is wasted effort when the bug lives in one third-party program. Check Event ID 1000 first and update or replace the named application.
  • Do not run more than one antivirus at a time. Real-time scanners that both hook process and thread activity can conflict with each other; rely on one security product plus periodic scans.
  • Do create restore points before major changes. A restore point costs seconds and gives you a clean escape route when a driver or update goes wrong.
  • Do keep one change per test. When troubleshooting, change one thing at a time; otherwise you cannot tell which fix worked.

FAQ#

Is ERROR_THREAD_NOT_IN_PROCESS a virus? No. It is a documented Windows system error code. However, malware that manipulates threads in other processes can trigger it, so a security scan is a sensible step.

What is error 0x236? It is the same error as 566 — just the hexadecimal form. If you see HRESULT 0x80070236, that is also the same code after conversion with HRESULT_FROM_WIN32.

Can bad RAM cause this error? Yes, in principle. Memory corruption can damage process and thread bookkeeping. Run the Windows Memory Diagnostic tool to rule hardware out, especially if the error appears in several unrelated applications.

The error only happens in one game or app. What should I try first? Update or reinstall that application, disable its overlays and third-party add-ons, and update your graphics driver. If the app itself has the bug, the vendor's support channel is the right place for a fix.

Does a System Restore delete my personal files? No. It reverts system files, drivers, applications, and registry settings to an earlier point. Documents and other personal files are not affected.

Conclusion#

ERROR_THREAD_NOT_IN_PROCESS (566 / 0x236) means a program asked Windows to operate on a thread that is not part of the process it named — often because a thread exited, an ID was reused, or a cross-process tool mixed up its handles. On the system side, the same message can surface from corrupted system files, conflicting background software, malware, outdated drivers, or failing hardware.

The reliable path to a fix is: identify the faulting application from Event Viewer, repair system files with DISM and SFC, isolate conflicts with a clean boot, scan for malware, update Windows and drivers, and check disk and memory. Use System Restore and the recovery options as your final steps. Developers can eliminate the error entirely by validating thread ownership before use, preferring handles over thread IDs, and treating the code as a recoverable condition. Follow those steps and the error thread not in process message should be a one-time curiosity rather than a recurring problem.

References#

  1. Microsoft Learn, System Error Codes 500–999 (WinError.h) — definition of ERROR_THREAD_NOT_IN_PROCESS (566 / 0x236).
  2. Microsoft Learn, MS-ERREF: Win32 Error Codes — standardized meaning of error 0x236.
  3. Microsoft Learn, MS-ERREF: NTSTATUS Values — STATUS_THREAD_NOT_IN_PROCESS (0xC000012A).
  4. Microsoft Learn, HRESULT_FROM_WIN32 function (winerror.h) — mapping from Win32 codes to HRESULT values.
  5. Microsoft Learn, Retrieving the Last-Error Code and FormatMessage function (winbase.h) — decoding system error codes in code.
  6. Microsoft Learn, !error (WinDbg) — decoding Win32 and NTSTATUS error values in the debugger.
  7. Microsoft Learn, CreateToolhelp32Snapshot function (tlhelp32.h) and Traversing the thread list — enumerating threads and their owning processes.
  8. Microsoft Support, Use the System File Checker tool to repair missing or corrupted system files — DISM and SFC repair workflow.
  9. Microsoft Support, How to perform a clean boot in Windows — isolating background software conflicts.
  10. Microsoft Support, Virus & threat protection in the Windows Security app — quick, full, custom, and offline scan options.
  11. Microsoft Support, Troubleshoot problems updating Windows and Automatically get recommended and updated hardware drivers.
  12. Microsoft Support, System Protection, Startup Repair, Windows startup settings, and Reset your PC.
  13. Microsoft Learn, Troubleshoot application or service crashing behavior — Event ID 1000 and 1001 crash diagnostics in Event Viewer.
  14. Microsoft Learn, chkdsk — checking volumes for file system errors.