Skip to content

Commit

Permalink
Made GuiCommandHandler.RunTask() robust against spurious Win32Exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianeicher committed Sep 20, 2022
1 parent ae23e83 commit 3918684
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/Commands.WinForms/GuiCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,30 @@ public override void RunTask(ITask task)

Log.Debug("Task: " + task.Name);

task.Run(CancellationToken, CredentialProvider, _wrapper.Post(form => form.AddProgressFor(task)));
_wrapper.Post(form => form.RemoveProgressFor(task));
IProgress<TaskSnapshot>? progress = null;
try
{
progress = _wrapper.Post(form => form.AddProgressFor(task));
}
#region Error handling
catch (Win32Exception ex)
{
Log.Debug($"Problem showing GUI progress control for {task.Name}", ex);
}
#endregion

task.Run(CancellationToken, CredentialProvider, progress);

try
{
_wrapper.Post(form => form.RemoveProgressFor(task));
}
#region Error handling
catch (Win32Exception ex)
{
Log.Debug($"Problem removing GUI progress control for {task.Name}", ex);
}
#endregion
}
#endregion

Expand Down

0 comments on commit 3918684

Please sign in to comment.