RFR: 8270269: Desktop.browse method fails if earlier CoInitialize call as COINIT_MULTITHREADED [v3]
Sergey Bylokhov
serb at openjdk.org
Mon Dec 11 20:41:14 UTC 2023
On Mon, 11 Dec 2023 19:24:34 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>How come? It can't change: once COM is initialised on a thread, its threading model cannot be changed. This is what RPC_E_CHANGED_MODE error code conveys, in other words you request initialising COM in a threading model that's different the model COM has been initialised previously.
Hmm for some reason after reading this doc I decided that the transition from STA to MTA is possible:
https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-coinitializeex
>RPC_E_CHANGED_MODE:
>A previous call to [CoInitializeEx](https://learn.microsoft.com/en-us/windows/desktop/api/combaseapi/nf-combaseapi-coinitializeex) specified the concurrency model for this thread as multithread apartment (MTA). This could also indicate that a change from neutral-threaded apartment to single-threaded apartment has occurred.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17010#issuecomment-1850851946
More information about the client-libs-dev
mailing list