diff options
author | Koundinya Veluri <kouvel@users.noreply.github.com> | 2018-08-12 18:35:48 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2018-08-12 18:35:48 -0700 |
commit | 3a56afe6de4113c83b66a5d3a467b8accfaafa1f (patch) | |
tree | f10824483e72490f493f69ae50abd9f9b3ac0dcf /src/vm/comwaithandle.cpp | |
parent | 4ccd7a52827a9078b35e167bea488b3389538e92 (diff) | |
download | coreclr-3a56afe6de4113c83b66a5d3a467b8accfaafa1f.tar.gz coreclr-3a56afe6de4113c83b66a5d3a467b8accfaafa1f.tar.bz2 coreclr-3a56afe6de4113c83b66a5d3a467b8accfaafa1f.zip |
Fix a couple of apartment state issues (#19384)
* Fix a couple of apartment state issues
Fix for https://github.com/dotnet/coreclr/issues/17822
- The apartment state now defaults to MTA for the main thread along with a CoInitialize
- Calling `Thread.SetApartmentState` with STA now fails as expected (different behavior from previous netcore, same behavior as netfx)
Fix for https://github.com/dotnet/coreclr/issues/17787
- `WaitHandle.WaitAll` for multiple handles is not supported on an STA thread due to issues described in https://github.com/dotnet/coreclr/issues/17787#issuecomment-385117537
- It now throws `NotSupportedException` as expected (different behavior from previous netcore, same behavior as netfx)
Fix for https://github.com/dotnet/coreclr/issues/19225
* Temporarily exclude invalid CoreFX test
Diffstat (limited to 'src/vm/comwaithandle.cpp')
-rw-r--r-- | src/vm/comwaithandle.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/vm/comwaithandle.cpp b/src/vm/comwaithandle.cpp index 7d0b7b738d..5e63ce21da 100644 --- a/src/vm/comwaithandle.cpp +++ b/src/vm/comwaithandle.cpp @@ -227,12 +227,14 @@ FCIMPL4(INT32, WaitHandleNative::CorWaitMultipleNative, Object* waitObjectsUNSAF PTRARRAYREF pWaitObjects = (PTRARRAYREF)waitObjects; // array of objects on which to wait int numWaiters = pWaitObjects->GetNumComponents(); - // Note: this should really be FEATURE_COMINTEROP_APARTMENT_SUPPORT. - // Because it's not, CoreCLR will allow WaitAll on STA threads. - // But fixing this would be a breaking change at this point, since we already shipped - // SL 2 and 3 this way. - // Perhaps in a future release we can fix this, if we aren't quite so concerned about - // compatibility.... +#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT + // There are some issues with wait-all from an STA thread + // - https://github.com/dotnet/coreclr/issues/17787#issuecomment-385117537 + if (waitForAll && numWaiters > 1 && pThread->GetApartment() == Thread::AS_InSTA) + { + COMPlusThrow(kNotSupportedException, W("NotSupported_WaitAllSTAThread")); + } +#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT WaitHandleArrayHolder arrayHolder; arrayHolder.Initialize(numWaiters, (PTRARRAYREF*) &waitObjects); |