Is there a library/framework to execute long running actions in .NET? Looking for something like this:
private void button1_Click(...)
{
LongActionRunner.Execute((ref int total, ref int done) => {
// i know it's not thread-safe
total = 100;
for(var i = 0; i <= 100; ++i) {
done = i;
Thread.Sleep(100); // slow
}
});
}
When Execute()
is called, I need to display a window with progress bar. If my action throws, it should display an error message, etc.
Are there any existing solutions?