I have a method to generate software activation key from User Information:
private async void GenerateAsync()
{
await Task.Run(() =>
You should use the more modern IProgress
/Progress
types:
var progress = new Progress(value => { progressBar.Value = value; });
await Task.Run(() => GenerateAsync(progress));
void GenerateAsync(IProgress progress)
{
...
progress?.Report(13);
...
}
This is better than Invoke
because it doesn't tie your business logic (GenerateAsync
) to a particular UI, or to any UI at all.