Introduction

The Microsoft Windows operating system offers many features and capabilities to application developers. Developers consume these features by calling Windows Runtime (WinRT) APIs. This book explores many of the Windows Runtime APIs and how to best use them from within your own applications. An emphasis is placed on using WinRT APIs from Windows Store apps. Windows Store app developers will also find a lot of architectural guidance as well as performance and debugging advice throughout all the book’s chapters.

In addition, since many WinRT APIs are available to desktop apps too, much of this book is also useful to desktop app developers. In particular, desktop app developers will get a lot from the chapters that cover files, folders, streams, networking, toasts, and the clipboard.

Although WinRT APIs can be invoked from many different programming languages—including JavaScript, native C++, and Visual Basic—this book focuses on consuming them from C# because this language is expected to be the most-used language for consuming WinRT APIs due to its popularity with Microsoft-centric developers and the enormous productivity the language provides. However, if you decide to use a different programming language, this book still provides a lot of information and guidance about the WinRT APIs, and this information is useful regardless of the programming language used to invoke them.

Who should read this book

This book is useful to developers building applications for the Windows operating system. It teaches core WinRT API concepts and how to architect and design Windows Store apps, and it provides performance and debugging tips throughout. Much of the information presented in this book is also useful to developers building desktop apps for Windows.

Assumptions

This book expects that you have at least a minimal understanding of the Microsoft .NET Framework, the C# programming language, and the Visual Studio integrated development environment. For more information about C# and the .NET Framework, consider reading Jeffrey Richter’s CLR via C#, Fourth Edition (Microsoft Press, 2012).

Who should not read this book

This book does not focus on user-interface concepts and how to design an app’s user interface using technologies such as XAML or HTML. For information about using XAML to build user interfaces, consider reading Charles Petzold’s Programming Windows: Writing Windows 8 Apps with C# and XAML, Sixth Edition (Microsoft Press, 2013).

Organization of this book

This book is divided into two sections. Part I focuses on concepts that all WinRT and Windows Store app developers must know.

  • Chapter 1 defines the WinRT type system, its principles, and how to consume it from various programming languages. This chapter also addresses the importance of understanding asynchronous programming, which is pervasive throughout the WinRT API.

  • Chapter 2 concentrates on the files that make up a Windows Store app, how those files get combined into a package file, and how the package file ultimately gets installed on users’ PCs. Package files are a new core concept in Windows, and understanding them is critical to being successful when using WinRT APIs.

  • Chapter 3 explains the core concepts related to how Windows Store apps execute. The chapter focuses on app activation, threading models, main view and hosted view windows, XAML page navigation, efficient memory management, process lifetime management, and debugging. All Windows Store apps must adhere to the architecture described in this chapter.

Part II contains chapters that explore various Windows facilities. The topics presented are key topics that almost all Windows Store app developers must know. Although the chapters can be read in any order, I recommend reading them in order because later chapters tend to reference topics presented in earlier chapters. Most of the chapters in Part II are about moving data around using settings, files, folders, streams, networking, and data sharing. However, there are also chapters explaining how apps can update tile content and display toasts. And there is a chapter explaining how apps can execute code when the user is not interacting with the app. The final chapter shows how to submit your app to the Windows Store and how to leverage the Windows Store commerce engine so that you can get paid for your development efforts.

Code samples

Most of the chapters in this book include code snippets showing how to leverage the various Windows features. Complete code samples demonstrating the features and allowing you to experiment with them can be downloaded from the following page:

http://Wintellect.com/Resource-WinRT-Via-CSharp

Follow the instructions to download the “WinRT via CS” .zip file.

Note

In addition to the code samples, your system must be running Windows 8.1 and must have Visual Studio 2013 installed.

The Visual Studio solution contains several projects. Each project starts with a two-digit number that corresponds to the book’s chapter. For example, the “05a-Storage” project contains the code that accompanies Chapter 5.

Acknowledgments

I couldn’t have written this book without the help and technical assistance of many people. In particular, I’d like to thank my family. The amount of time and effort that goes into writing a book is hard to measure. All I know is that I could not have produced this book without the support of my wife, Kristin, and my two sons, Aidan and Grant. There were many times when we wanted to spend time together but were unable to due to book obligations. Now that the book project is completed, I really look forward to adventures we will all share together.

Of course, I also have to thank my coauthor, Maarten van de Bospoort. This book would not have existed at all if it were not for Maarten. Maarten started with my original course slides and demo code and turned that into the chapter text. Because books go into more technical depth and detail than courses, he had to research many areas in further depth and embellish the chapters quite a bit. Maarten would then hand the chapters over to me, and I would polish them by reorganizing a bit and add my own personal flair. It was a pleasure working with Maarten as he was always open to suggestions, and it was also really nice to have someone to discuss book organization and content with.

For technical content, there are many people on Microsoft’s Windows team who had one-on-one meetings with me so that I could learn more about the features and their goals. In particular, I had two six-hour meetings with Howard Kapustein discussing packages, app containers, deployment, bundles, and so on. Talks with him changed my whole view of the system, and the chapters in this book reflect what I learned from these discussions. John Sheehan also spoke with me at length about package capabilities, declarations, and the resource system, which changed my whole view about app activation and contracts. Many others also had conversations with me about the WinRT type system, files, networking, background tasks, sharing, the Windows Store, tiles and toasts, and more. These people include Chris Anthony, Tyler Beam, Manoj Biswas, Arik Cohen, David Fields, Alain Gefflaut, Chris Guzak, Guanghui He, Scott Hoogerwerf, Suhail Khalid, Salahuddin Khan, Nathan Kuchta, Jon Lam, Nancy Perks, Hari Pulapaka, Brent Rector, Jamie Schwartz, Peter Smith, Ben Srour, Adam Stritzel, Henry Tappen, Pedro Teixeira, Dave Thaler, Marc Wautier, Sarah Waskom, and Terue Yoshihara.

As for editing and producing the book, I truly had some fantastic people helping me. Christophe Nasarre, who I’ve worked with on several book projects, has once again done just a phenomenal job ensuring that technical details are explained accurately. He has truly had a significant impact on the quality of this book. As always, the Microsoft Press team is a pleasure to work with. I’d like to extend a special thank you to Devon Musgrave and Carol Dillingham. Also, thanks to Curt Philips, Roger LeBlanc, and Andrea Fox for their editing and production support.

Errata & book support

We’ve made every effort to ensure the accuracy of this book and its companion content. Any errors that have been reported since this book was published are listed at:

http://aka.ms/WinRTviaCsharp/errata

If you find an error that is not already listed, you can report it to us through the same page.

If you need additional support, email Microsoft Press Book Support at:

.

Please note that product support for Microsoft software is not offered through the addresses above.

We want to hear from you

At Microsoft Press, your satisfaction is our top priority, and your feedback our most valuable asset. Please tell us what you think of this book at:

http://aka.ms/tellpress

The survey is short, and we read every one of your comments and ideas. Thanks in advance for your input!

Stay in touch

Let’s keep the conversation going! We’re on Twitter: http://twitter.com/MicrosoftPress

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.170.83