diff options
author | Anton Lapounov <antonl@microsoft.com> | 2016-09-10 05:40:45 +0300 |
---|---|---|
committer | Anton Lapounov <antonl@microsoft.com> | 2016-09-10 05:40:45 +0300 |
commit | d0866e0ac33b2600fd9ab3f1e0156bb5464176e6 (patch) | |
tree | 58ea16545c93a0b003df5d9d54849d4ac8191215 /src/Native/Runtime/windows | |
parent | 92c75e6c934ae7a6b00061f8dea19b395d7569cb (diff) |
Fix WinRT interop for mrt150 runtime
CR: SergeyK, JKotas, MorganB
Change 1619259 moved the RoInitialize call for the main thread to the mrt100_app runtime. Call RoInitialize in the mrt150 runtime in the same manner until we have non-WinRT framework for classic apps.
[tfs-changeset: 1626616]
Diffstat (limited to 'src/Native/Runtime/windows')
-rw-r--r-- | src/Native/Runtime/windows/PalRedhawkMinWin.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Native/Runtime/windows/PalRedhawkMinWin.cpp b/src/Native/Runtime/windows/PalRedhawkMinWin.cpp index 9c4139627..b17b7da1b 100644 --- a/src/Native/Runtime/windows/PalRedhawkMinWin.cpp +++ b/src/Native/Runtime/windows/PalRedhawkMinWin.cpp @@ -17,6 +17,9 @@ #include <stdio.h> #include <errno.h> #include <evntprov.h> +#ifndef CORERT +#include <roapi.h> +#endif #include "holder.h" @@ -1325,6 +1328,10 @@ REDHAWK_PALEXPORT _Ret_maybenull_ void* REDHAWK_PALAPI PalSetWerDataBuffer(_In_ static LARGE_INTEGER g_performanceFrequency; +#ifndef CORERT +static bool g_roInitialized; +#endif + // Initialize the interface implementation // Return: // true if it has succeeded, false if it has failed @@ -1335,12 +1342,37 @@ bool GCToOSInterface::Initialize() return false; } +#ifndef CORERT + // TODO: Remove the RoInitialize call when we implement non-WinRT framework for classic apps + HRESULT hr = RoInitialize(RO_INIT_MULTITHREADED); + + // RPC_E_CHANGED_MODE indicates this thread has been already initialized with a different + // concurrency model. That is fine; we just need to skip the RoUninitialize call on shutdown. + if (SUCCEEDED(hr)) + { + g_roInitialized = true; + } + else if (hr != RPC_E_CHANGED_MODE) + { + return false; + } +#endif + return true; } // Shutdown the interface implementation +// Remarks: +// Must be called on the same thread as Initialize. void GCToOSInterface::Shutdown() { +#ifndef CORERT + if (g_roInitialized) + { + RoUninitialize(); + g_roInitialized = false; + } +#endif } // Get numeric id of the current thread if possible on the |