| Flutter Windows Embedder |

Public Member Functions | List of all members
flutter::ThreadSnapshot Class Reference

## Public Member Functions
| ThreadSnapshot ()
| ~ThreadSnapshot ()
std::optional< THREADENTRY32 > | GetFirstThread ()
bool | GetNextThread (THREADENTRY32 &thread)

## Detailed Description

Definition at line 107 of file windows_lifecycle_manager.cc.

## Constructor & Destructor Documentation

## ◆ ThreadSnapshot()

flutter::ThreadSnapshot::ThreadSnapshot | ( |  | ) |
| inline

Definition at line 109 of file windows_lifecycle_manager.cc.

109 {
110 thread_snapshot_ = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
111 }

## ◆ ~ThreadSnapshot()

flutter::ThreadSnapshot::~ThreadSnapshot | ( |  | ) |
| inline

Definition at line 112 of file windows_lifecycle_manager.cc.

112 {
113 if (thread_snapshot_ != INVALID_HANDLE_VALUE) {
114 ::CloseHandle(thread_snapshot_);
115 }
116 }

## Member Function Documentation

## ◆ GetFirstThread()

std::optional<THREADENTRY32> flutter::ThreadSnapshot::GetFirstThread | ( |  | ) |
| inline

Definition at line 118 of file windows_lifecycle_manager.cc.

118 {
119 if (thread_snapshot_ == INVALID_HANDLE_VALUE) {
120 FML_LOG(ERROR) << "Failed to get thread snapshot";
121 return std::nullopt;
122 }
123 THREADENTRY32 thread;
124 thread.dwSize = sizeof(thread);
125 if (!::Thread32First(thread_snapshot_, &thread)) {
126 DWORD error_num = ::GetLastError();
127 char msg[256];
128 ::FormatMessageA(
129 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
130 error_num, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), msg, 256,
131 nullptr);
132 FML_LOG(ERROR) << "Failed to get thread(" << error_num << "): " << msg;
133 return std::nullopt;
134 }
135 return thread;
136 }

Referenced by flutter::WindowsLifecycleManager::IsLastWindowOfProcess().

## ◆ GetNextThread()

bool flutter::ThreadSnapshot::GetNextThread | ( | THREADENTRY32 & | thread | ) |
| inline

Definition at line 138 of file windows_lifecycle_manager.cc.

138 {
139 if (thread_snapshot_ == INVALID_HANDLE_VALUE) {
140 return false;
141 }
142 return ::Thread32Next(thread_snapshot_, &thread);
143 }

Referenced by flutter::WindowsLifecycleManager::IsLastWindowOfProcess().

The documentation for this class was generated from the following file:

- shell/platform/windows/windows_lifecycle_manager.cc