terminal/src/interactivity/win32/ConsoleInputThread.cpp
Michael Niksa 7478248564
Add names to threads to make debugging a slight bit easier (#9801)
Add names to threads to make debugging a slight bit easier.

## PR Checklist
* [x] Closes personal todo item.
* [x] I work here.
* [x] Tested manually.

## Detailed Description of the Pull Request / Additional comments
Thread descriptions show up as names in both the Visual Studio debugger, WinDBG debugger, and Windows Performance Analyzer. This makes it faster and easier to identify threads of interest in our processes.

## Validation Steps Performed
* [x] Checked threads were named in OpenConsole.exe running in classic conhost window mode under VS debug
* [x] Checked threads were named in OpenConsole.exe running in conpty mode under VS debug
* [x] Checked threads were named in WindowsTerminal.exe (for a few of the threads around connections)
* [x] Checked that we could also see it in WinDBG
2021-04-14 10:56:52 +00:00

35 lines
866 B
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "precomp.h"
#include "ConsoleInputThread.hpp"
#include "WindowIo.hpp"
using namespace Microsoft::Console::Interactivity::Win32;
// Routine Description:
// - Starts the Win32-specific console input thread.
HANDLE ConsoleInputThread::Start()
{
HANDLE hThread = nullptr;
DWORD dwThreadId = (DWORD)-1;
hThread = CreateThread(nullptr,
0,
ConsoleInputThreadProcWin32,
nullptr,
0,
&dwThreadId);
if (hThread)
{
_hThread = hThread;
_dwThreadId = dwThreadId;
LOG_IF_FAILED(SetThreadDescription(hThread, L"Win32 Window Message Input Thread"));
}
return hThread;
}