From 3c7bda7bbb34314db8e949a433f09ccff2779be3 Mon Sep 17 00:00:00 2001 From: Tian L <60599517+tian-lt@users.noreply.github.com> Date: Fri, 9 Apr 2021 14:29:02 +0800 Subject: [PATCH] NavCategory: temporary resolution of the hang issue (#9) --- src/CalcViewModel/Common/NavCategory.cpp | 33 +++++------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/src/CalcViewModel/Common/NavCategory.cpp b/src/CalcViewModel/Common/NavCategory.cpp index f23f46e1..f61f6830 100644 --- a/src/CalcViewModel/Common/NavCategory.cpp +++ b/src/CalcViewModel/Common/NavCategory.cpp @@ -62,33 +62,12 @@ bool IsGraphingModeAvailable() Box ^ _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 ^ 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; }