0
I made a lib to manage the part of a system of mine, until then everything is ok, the problem occurs when this lib launches an Exception:
public async void Update(ObjetoPostalModel objeto)
{
await LogarAsync(0);
if (Validacao.Sucesso == false)
{
throw new Exception(Validacao.Mensagem);
}
}
At that moment the system closes, as it launched this Exception, how do I return the error message:
I’m using this Lib as follows:
private async Task AtualizaUpdate()
{
void run()
{
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
{
lib.AguardandoUpdate++;
lib.Update();
}));
}
}
Task task = Task.Run(run);
await Task.WhenAll(task);
}
To call this method within my system I use:
try
{
await AtualizaUpdate();
lib.AguardandoUpdate--;
}
catch (Exception ex)
{
lib.AguardandoUpdate--;
NotificacaoUtil.Error(ex.Message);
}