so that these tasks do not freeze the applications that use them.
If this is your goal, you should study the standard asynchronous programming patterns within the framework.
If your library is targeting .NET 4, return it to Task and Task<T> , as this will make it easier to switch to async support in the next version of C # and VB.NET. It also has a very nice addition allowing you to use synchronous use without any additional work on your part, as the user can always just do:
var result = foo.BarAsync().Result;
If you plan to use .NET 3.5 or earlier, you should consider using an asynchronous event-based template , as it is used in more existing APIs than APM.
source share