简体   繁体   English

是否可以提供WinRT服务

[英]Is it possible to make a WinRT service

Since WinRT have unique capabilities, I wonder if it were to make a Windows Service that is targeted to WinRT? 由于WinRT具有独特的功能,我想知道是否要制作针对WinRT的Windows服务? If it were not possible, is the workaround to make an invisible WinRT/Metro application possible? 如果不可能,是否可以使不可见的WinRT / Metro应用程序变通?

Thanks a lot. 非常感谢。

No is the correct answer. 否是正确答案。 A metro application executes inside the Metro shell and inside an execution container that creates a sandbox away from system resources, including services. Metro应用程序在Metro Shell内和执行容器内执行,该执行容器在远离系统资源(包括服务)的位置创建沙箱。 For this reason a metro app cannot access a local service. 因此,地铁应用无法访问本地服务。 Similarly, for this reason, a metro app cannot be a service. 同样,由于这个原因,地铁应用程序不能成为服务。

Background tasks and push notifications through Windows Notification Services are the only way for a metro app to interact with the user while not active. 通过Windows Notification Services进行后台任务和推送通知是Metro应用程序在不活动时与用户进行交互的唯一方法。 Otherwise, when the application is not active (not visible), all of its threads are suspended (unlike a service). 否则,当应用程序处于非活动状态(不可见)时,其所有线程都将被挂起(与服务不同)。

As for background tasks, their activity is constrained identically to a metro app and limited to a single CPU second every 2 hours (there is one exception). 对于后台任务,它们的活动与Metro应用程序相同,并且每2小时限制在一个CPU秒内(有一个例外)。 Push notifications can execute more frequently, but are only capable of updating a tile or raising a toast notification. 推送通知可以更频繁地执行,但只能更新磁贴或举起吐司通知。

The intent of a metro application is different than a traditional desktop application: Metro应用程序的意图不同于传统的桌面应用程序:

Metro applications are architecture independent (run on intel or arm). Metro应用程序与体系结构无关(在Intel或Arm上运行)。 Metro applications are touch-reach, built for touch screens. Metro应用程序是触摸式的,专为触摸屏构建。 Metro applications are fully hardware accelerated. Metro应用程序完全由硬件加速。 Metro applications leverage the next gen hardware that certified devices offer, including unprecedented battery life. Metro应用程序利用经过认证的设备提供的下一代硬件,包括前所未有的电池寿命。 Metro applications are the only applications delivered by the Windows store. Metro应用程序是Windows应用商店提供的唯一应用程序。

Look, choosing a metro application does mean to concede some of the unlimited power of desktop applications. 看,选择Metro应用程序确实意味着要放弃桌面应用程序的某些无限功能。 However, the gains are significant, too. 但是,收益也很可观。

Nope this isn't possible (wither the service, or the "invisible" metro application). 不,这是不可能的(通过服务或“不可见”的Metro应用程序)。

You can run background tasks that may do what you are after, but without understanding your problem I couldn't say. 您可以运行后台任务,这些任务可能会执行您要执行的任务,但是在不理解您的问题的情况下我无法说。

It depends on what you want to do. 这取决于您想做什么。

WinRT is an API and can be accessed from Metro (Windows Store) Apps and from Desktop/C# apps. WinRT是一种API,可以从Metro(Windows Store)应用程序和Desktop / C#应用程序进行访问。

However not the full API is exposed - see what you are allowed to access here: http://msdn.microsoft.com/en-us/library/windows/desktop/hh920511%28v=vs.85%29.aspx 但是未公开完整的API-请在此处查看允许您访问的内容: http : //msdn.microsoft.com/zh-cn/library/windows/desktop/hh920511%28v=vs.85%29.aspx

Hanselman shows how to add a ref to WinRT: Hanselman展示了如何向WinRT添加参考:

  • Edit the csproj: 编辑csproj:
 <PropertyGroup> <TargetPlatformVersion>8.0</TargetPlatformVersion> </PropertyGroup> 
  • Then add a reference to Core/Windows. 然后添加对Core / Windows的引用。

http://www.hanselman.com/blog/HowToCallWinRTAPIsInWindows8FromCDesktopApplicationsWinRTDiagram.aspx http://www.hanselman.com/blog/HowToCallWinRTAPIsInWindows8FromCDesktopApplicationsWinRTDiagram.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM