0
The method RelatoriosEstaticos.AbrirDataAtual which is within the Task below is returning an exception already dealt with in the method itself, the problem is that the Task continues the execution of the next line var links = Filelist.Listsdownlaod(driver); which depends on the method Startingcurrent to be executed, with this, she also throws an exception. I have tried to deal within the method, put the task inside a try/catch, but nothing works, always occurs the exception in the method Listsdownlaod and you shouldn’t even get there.
How can I interrupt the execution of the task, as it happens when we send a Cancellationtoken, but this time when any exception occurs.
private async Task<List<IWebElement>> Acessar(IWebDriver driver, string data, CancellationToken ct)
{
return await Task.Run(() =>
{
ct.ThrowIfCancellationRequested();
LoginNgin.Login(config.User, config.Password, driver);
RelatoriosEstaticos.AbrirRelatoriosEstaticos(driver);
RelatoriosEstaticos.AbrirDataAtual(driver, data);
var links = ListArquivos.ListaLinksDownlaod(driver);
MethodInvoker action = delegate { pgbStatus.Maximum = links.Count(); };
pgbStatus.BeginInvoke(action);
return links;
});
}
Are you debugging right to understand what is really going on? and why are the exceptions not being dealt with? apparently the logic of your code isn’t making much sense.
– M. Bertolazo
Yeah, I debugged the code. as I said, an exception is being cleared in the current Abrir() method; this exception is already properly dealt with within the method, the problem is that even with this exception, the task ignores and continues the execution of the code.
– Gabriel Bernardone