In this recipe, we will see how to convert an old-fashioned APM API to a task. There are examples of different situations that could happen in the process of conversion.
To start this recipe, you will need Visual Studio 2012. There are no other prerequisites. The source code for this recipe can be found at
For converting the APM pattern to tasks, perform the following steps:
Program.csfile, add the following
using System; using System.Threading; using System.Threading.Tasks;
private delegate string AsynchronousTask(stringthreadName); ...