Hello,
Welcome to our Microsoft Q&A platform!
By checking your code, the ProgressRing you used is correct and the issue occurs because the for loop blocks the thread, it will be blocked until the function stops. So, before you do compute-bound work in a coroutine, you need to return execution to the caller (in other words, introduce a suspension point) so that the caller isn't blocked. If you're not already doing that by co_await-ing some other operation, then you can co_await the winrt::resume_background function. For updating UI, you can co_await the winrt::resume_foreground function to switch to a specific foreground thread. For more details about concurrency and asynchrony, you can refer to this document.
#include "winrt/Windows.UI.Core.h"
Windows::Foundation::IAsyncAction MainPage::ClickHandler(IInspectable const&, RoutedEventArgs const&)
{
pring().IsActive(true);// Set loading to true
pring().UpdateLayout();
myButton().Content(box_value(L"Clicked"));
co_await winrt::resume_background();
loopPrime(500000); //Long running operation here
co_await winrt::resume_foreground(pring().Dispatcher());
pring().IsActive(false);// Set to false when done
}
Thanks