Patterns and best practices
In mobile applications, developers often use certain reusable design patterns while using web services and other communication channels in development projects. These patterns aim to increase the efficiency and increase the code sharing not only between platforms but also among various execution domains of cross-platform mobile applications.
Async conversions
The generated proxies for WCF and/or SOAP/XML services generally include either an event-based async implementation or an asynchronous invoke pattern with begin and end methods. Both of these implementations can be converted to a task-based async pattern.
In order to convert the event-based async service method to a task-based one, we can use TaskCompletionSource<T>
and return the task that is produced (refer to Chapter 3, Asynchronous Programming).
public Task<List<Region>> GetRegionsAsync(Region filter = null) { var taskAwaiter = new TaskCompletionSource<List<Region>>(); ...