I'm completely new to C# 5's new async
/await
keywords and I'm interested in the best way to implement a progress event.
Now I'd prefer it if a Progress
event was on the Task<>
itself. I know I could just put the event in the class that contains the asynchronous method and pass some sort of state object in the event handler, but to me that seems like more of a workaround than a solution. I might also want different tasks to fire off event handlers in different objects, which sounds messy this way.
Is there a way I could do something similar to the following?:
var task = scanner.PerformScanAsync();
task.ProgressUpdate += scanner_ProgressUpdate;
return await task;