-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
area-templatesProject templates, Item Templates for Blazor and MAUIProject templates, Item Templates for Blazor and MAUIpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaboration
Milestone
Description
Hi, I noticed the new VS project template for MAUI for .NET 9 has the following code:
Why is async lock (SemaphoreSlim) used here for Shell.DisplayAlert?
/// <summary>
/// Modal Error Handler.
/// </summary>
public class ModalErrorHandler : IErrorHandler
{
SemaphoreSlim _semaphore = new(1, 1);
/// <summary>
/// Handle error in UI.
/// </summary>
/// <param name="ex">Exception.</param>
public void HandleError(Exception ex)
{
DisplayAlert(ex).FireAndForgetSafeAsync();
}
async Task DisplayAlert(Exception ex)
{
try
{
await _semaphore.WaitAsync();
if (Shell.Current is Shell shell)
await shell.DisplayAlert("Error", ex.Message, "OK");
}
finally
{
_semaphore.Release();
}
}
}
Thanks
Metadata
Metadata
Assignees
Labels
area-templatesProject templates, Item Templates for Blazor and MAUIProject templates, Item Templates for Blazor and MAUIpartner/syncfusionIssues / PR's with Syncfusion collaborationIssues / PR's with Syncfusion collaboration
