Skip to content

Commit 6da670a

Browse files
bmehta001Copilot
andcommitted
Initialize the WinRT listener apartment
Use RoInitialize with the multithreaded apartment and balance successful initialization with RoUninitialize so Windows Runtime activation is valid on every supported Windows target. Verified at: - lib/pal/desktop/NetworkDetector.cpp Files changed: - lib/pal/desktop/NetworkDetector.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: df9f344e-e064-404e-ae6f-c0ef455d747c
1 parent ffc696e commit 6da670a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎lib/pal/desktop/NetworkDetector.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,20 @@ namespace MAT_NS_BEGIN
225225
#pragma warning(disable:6320)
226226
void NetworkDetector::run()
227227
{
228-
bool isCoInitialized = false;
228+
bool isRoInitialized = false;
229229

230230
__try
231231
{
232232
__try
233233
{
234-
HRESULT hr = CoInitialize(nullptr);
234+
HRESULT hr = RoInitialize(RO_INIT_MULTITHREADED);
235235
if (FAILED(hr))
236236
{
237-
LOG_ERROR("CoInitialize Failed.");
237+
LOG_ERROR("RoInitialize failed.");
238238
return;
239239
}
240240

241-
isCoInitialized = true;
241+
isRoInitialized = true;
242242
if (GetNetworkInfoStats())
243243
{
244244
GetCurrentNetworkCost();
@@ -256,9 +256,9 @@ namespace MAT_NS_BEGIN
256256
LOG_ERROR("Handled exception in Windows Runtime network cost detection.");
257257
}
258258

259-
if (isCoInitialized)
259+
if (isRoInitialized)
260260
{
261-
CoUninitialize();
261+
RoUninitialize();
262262
}
263263

264264
}

0 commit comments

Comments
 (0)