How to activate ProgressRing before synchronous call #8329
-
I am trying to activate a ProgressRing (ProgressRing.IsActive = true) prior to calling a synchronous methods in MailKit to send an email. With a good internet connection, the process usually takes about 3-4 seconds, during which time I'd like the ProgressRing to spin. But it seems that the MailKit threads take over and complete before the interface has time to react, and the ProgressRing just sits idle. You can recreate this situation with the following simple code. How can I work around this? XAML: <ProgressRing x:Name="ProgressRingSendMail" IsActive="False""/> C#:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Well, you shouldn't be hanging the UI thread as in most cases it is going to be completely frozen the whole time. Here though the GPU takes care of the animation once the UI has flushed the render cycle. The time to next flush would depend on your refresh rate, but ~20ms would handle most cases, so: await Task.Delay(20); after setting |
Beta Was this translation helpful? Give feedback.
Well, you shouldn't be hanging the UI thread as in most cases it is going to be completely frozen the whole time. Here though the GPU takes care of the animation once the UI has flushed the render cycle. The time to next flush would depend on your refresh rate, but ~20ms would handle most cases, so:
after setting
IsActive
.