I’m trying to implement async calls with the new Async/Await pattern in visual studio 2012. When i set up my form (using the form designer) and then try to use an async method as an event handler, the compiler complains that the function doesn’t return void.
The method is supposed to return a Task; that’s the whole point. I cant figure out how to tell the form designer that this isn’t a regular event handler. Has anyone run into this issue? should i quit using the form designer for Rapid Development?
You have to use an
async voidmethod for the event handler, instead ofasync Task. Being able to wire up event handlers to async methods is the entire reasonasync voidis allowed.For example, if you want to use a button click handler, you’d write it like: