Book Image

Mastering Cross-Platform Development with Xamarin

Book Image

Mastering Cross-Platform Development with Xamarin

Overview of this book

The main goal of this book is to equip you with the required know-how to successfully analyze, develop, and manage Xamarin cross-platform projects using the most efficient, robust, and scalable implementation patterns. This book starts with general topics such as memory management, asynchronous programming, local storage, and networking, and later moves onto platform-specific features. During this transition, you will learn about key tools to leverage the patterns described, as well as advanced implementation strategies and features. The book also presents User Interface design and implementation concepts on Android and iOS platforms from a Xamarin and cross-platform perspective, with the goal to create a consistent but native UI experience. Finally, we show you the toolset for application lifecycle management to help you prepare the development pipeline to manage and see cross-platform projects through to public or private release.
Table of Contents (19 chapters)
Mastering Cross-Platform Development with Xamarin
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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>>();

...