Hello @Bhuwan ,
The error means that the method cannot be called in Main/UI thread, you could try to run the code on another thread by Task.Run Method :
Task.Run( () => {
...
}
In addition, you could try to use Xamarin.Essentials and determine if code is running on the Main Thread:
if (MainThread.IsMainThread)
{
// Code to run if this is the main thread
}
else
{
// Code to run if this is a secondary thread
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.