NavCategory: temporary resolution of the hang issue (#9)

This commit is contained in:
Tian L 2021-04-09 14:29:02 +08:00 committed by GitHub
commit 3c7bda7bbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,33 +62,12 @@ bool IsGraphingModeAvailable()
Box<bool> ^ _isGraphingModeEnabledCached = nullptr;
bool IsGraphingModeEnabled()
{
if (!IsGraphingModeAvailable())
{
return false;
}
if (_isGraphingModeEnabledCached != nullptr)
{
return _isGraphingModeEnabledCached->Value;
}
User ^ firstUser;
std::atomic_flag finished = ATOMIC_FLAG_INIT;
finished.test_and_set(std::memory_order_acquire); // acquire
create_task(User::FindAllAsync(UserType::LocalUser)).then([&firstUser, &finished](IVectorView<User ^> ^ users) {
firstUser = users->GetAt(0);
finished.clear(std::memory_order_release); // release
}, task_continuation_context::use_arbitrary());
while (finished.test_and_set(std::memory_order_acquire)) // aquire
; // spin
finished.clear(std::memory_order_release); // release
auto namedPolicyData = NamedPolicy::GetPolicyFromPathForUser(firstUser, L"Education", L"AllowGraphingCalculator");
_isGraphingModeEnabledCached = namedPolicyData->GetBoolean() == true;
// CSHARP_MIGRATION: TODO: merge PR ##1471 to fix below bug before we release to PROD
#ifdef _DEBUG
_isGraphingModeEnabledCached = true;
#else
throw "CSHARP_MIGRATION: EXCEPTION";
#endif // _DEBUG
return _isGraphingModeEnabledCached->Value;
}