Windows Runtime (winrt) secrets

Source: Internet
Author: User
Tags gtk

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 its own system is used to create applications on appstore.Program.
    • 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 ClassAddtwo
{
Public IntAdd (IntA,IntB)
{
ReturnA + B;
}

PublicAsync iasyncoperation subasync (IntA,IntB)
{
ReturnA-await (counteverybitbyhand (B ));
}
}

You will find the aboveCodeThere is no form of COM declaration. The only restriction is that the class must be sealed (unless you are creating a xaml ui component, this restriction is exposed in this case)

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.

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.