Windows Runtime (WinRT) secrets

Source: Internet
Author: User

After reading a build ppt, Windows Runtime (RT) is not as self-waste as some news websites say. NET martial arts, but on the contrary, WinRT is a modern version of Win32API, which has a deep understanding. NET gene, which belongs to Metro UI.. NET. If you evaluate the Metadata changes, the Metadata defined by the WinRT API is based on the standard ECMA 335, that is.. NET standard. WinRT is also a sandbox environment designed for the AppStore environment.

Basic knowledge
Microsoft took the launch of Windows 8 as an opportunity to solve Windows's long-term problems and bring a new user interface, making Windows more secure and the business model of AppStore. Microsoft has built the third XAML-based UI System in Windows 8. WPF is just a supply. the xaml ui system Silverlight used in the NET circle is only the xaml ui system used by the browser. Windows Phone7 transfers Silverlight to the mobile phone, now I bring XAML to all the systems that cover PCs, Pad, and Phone (although Microsoft thinks that tablets are also PCs, I still want to call them Pad, iPad users know that the Pad defined by Apple is very different from PC ).
. NET developers. net p/Invoke and COM Interop are very familiar, these two technologies make. NET personnel can use Win32 API and COM components. Mono also uses P/Invoke technology to create native libraries, such as Gtk # bound to Gtk + API, and MonoMac bound to Cocoa API, qyoto is bound to the Qt API. Mono has come up with innovative products such as MonoTouch, MonoDroid, and MonoMac. COM Interop also allows C/C ++ to import Com-type libraries from C.
There are many ways to create a native library, but these tasks have to be done manually, which is tedious and error-prone. From this point, WinRT is also very innovative, all developers can use the same model to create Metro UI applications.
WinRT
WinRT is a new API set with the following features:
It implements the UI library of Metro UI specifications
Provides a simple UI Programming Model for Windows developers. You do not need to learn the complex APIs of Win32API.
It uses the XAML-base UI System
All APIs are designed as Asynchronous
Like. NET, it is a sandbox API and is a self-built system used to create applications on the AppStore.
The API metadata format is ECMA335, which is the same as that of. NET. Does this mean that Mono can implement such an API in xUnit in the future?
The new user interface system encapsulated by WinRT is the upper layer of Com, just like Win32API.
WinRT Projections
What we call "Binding" is now called "Projections" and a new term. Projections is the process of exposing interfaces to three environments Native (C and C ++), HTML/Javascript, and. NET. So on Win8, developers can still use different tools, but they use a unified model.
If developers use components written in. NET or C ++, their APIs are stored in a WinMD file, and you can use them in three environments (native, javascript, And. NET ). Even if your component is written in C ++, it does not need to be exposed through COM. It is more like an object-oriented C ++ API.
The underlying layer of WinRT defines a set of basic types and ing between various environments. Is this similar to the support of different languages in the. NET environment.
Asynchronous API
Microsoft believes that when giving developers a choice to use synchronous and asynchronous APIs, developers will choose simple synchronous APIs. NET programming practices have been proved ,. NET has a very mature asynchronous programming model, and F # specially designed for parallel and asynchronous processing. What is the result? You may be aware of it.
In WinRT, Microsoft has always followed a simple rule: if an API is expected to take more than 50 milliseconds, the API is asynchronous, that is, the API is asynchronous, this ensures the best operation experience on the Metro UI.
Asynchronous programming has always been a complicated process, including the reconciliation status and exception handling. To simplify this process, C # and VB have also extended the support for F #-converted red await/async models, making asynchronous programming a joy.
Does. NET's first position disappear?
In previous news, I have been questioning. NET. Microsoft has abandoned it. Of course not. Not all. NET APIs are integrated into WinRT, but only a subset.
When you use C # and VB, you use the complete. NET Framework. However, they only expose a small subset of APIs to Windows 8 developers. You may think that I can use some tips to use the entire. NET. If your program does not need to be submitted to the AppStore for Microsoft review, this is OK. This strategy is obviously learned from Apple.
Take this opportunity. NET team also. NET, mscorlib. dll and System. dll has been split into different library headers, with the release of Win8. the NET version is 4.5, that is. NET 4.5 is not. NET 4 simple patch package, added a lot of things, ASP. the NET version is also 4.5, unlike. NET 2.0 ~ 3.5 SP1 and ASP.net versions are still 2. 0. In order to develop in Win8, it is necessary to start learning. NET 4.5. Here we focus on client development. Similarly, in terms of server development,. NET 4.5 also adds a lot of dry work.
Create a WinRT component
Although WinRT supports many languages, Microsoft only uses C ++ and. NET to demonstrate how to develop a WinRT component. Using. NET to develop WinRT components is much easier than C ++. Not all. NET features can be used. For example, private fields cannot be used in component classes, and tasks cannot be used in asynchronous APIs, instead of IAsyncOperation.
Public sealed class AddTwo
{
Public int Add (int a, int B)
{
Return a + B;
}

Public async IAsyncOperation SubAsync (int a, int B)
{
Return a-await (CountEveryBitByHand (B ));
}
}
You will find that the above Code does not have any form of COM declaration. The only restriction is that the class must be sealed (unless you are creating a xaml ui component, in this case, this restriction is exposed)
UI Programming
When it comes to user interface development, you can use HTML and CSS styles or use XAML to your application user interface. When you return to the interface layer, you can use HTML & CSS or xaml ui. The interface made with HTML & Css is Web, but a Windows application, as early as Vista, there was a similar application. It was improved on Windows 7, called Gadgets. Windows 8 evolved to the Metero UI, and C ++ ,. NET.
The development framework of Windows 8 is not based on HTML5 and JavaScript. developers can use native C ++, C #, and Silverlight to develop flat and touch-friendly applications, HTML5 and JavaScript provide only one option.

Author: Jungle tigers"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.