I'm trying to invoke an event within a Parallel.ForEachAsync, and it's hanging my UI or erroring back to the program.cs
The event on my class is being consumed by the UI to increment a progress bar. It works great when done in a foreach but not in the Parallel.ForEachAsync. I've tried to make my event async but that did not help any.
await Parallel.ForEachAsync<Individual>(INDlist, async (individual, token) =>
{
if (Cancel) throw new OperationCanceledException("Interface cancelled by the user");
await UpdateIndividualAsync(individual);
await IncrementProgress?.Invoke(this, EventArgs.Empty);
});
The issue was solved by firing the event less often. As the event was consumed by the UI it seemed to overwhelm it