5

I am trying to build a Windows 8 "metro-style" app that will operate as a "app killer". For those of you who have used Win8 (Tech Preview) you'll notice that once you open a metro-style app you cannot close it (without going into Task Manager and ending the process).

My challenge is that I cannot access 'System.Diagnostics.Process' from my metro-style app, nor do I know if there is an comparable alternative within the WinRT. I also thought of building a separate app that hosts a service for my metro app to interface with, but I'd like to do this with a single app.

Fundamentally, I am looking for a pattern for building Metro-style apps that leverage .NET 4.0 components, specifically to be able to enumerate and kill other processes running on the PC.

CLARIFICATION: I am less concerned with this specific application than I am with access that type of .NET functionality within a Metro-style app

Thanks

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Glenn Ferrie
  • 10,290
  • 3
  • 42
  • 73
  • 1
    Surely can't be true that once opened an app cannot be closed. – David Heffernan Oct 16 '11 at 20:24
  • 2
    There is no UI action besides Alt+F4 to close the Metro-style application. I believe this is by design. you can DL the OS at dev.windows.com and try it yourself. – Glenn Ferrie Oct 16 '11 at 20:26
  • 1
    OK, so you can close the app then! – David Heffernan Oct 16 '11 at 20:27
  • 1
    true. i'm more concerned with the Metro-style to .NET4 interaction. This is just a sample app to frame it. any ideas? – Glenn Ferrie Oct 16 '11 at 20:33
  • 3
    You can move the pointer to the top of the window until is turns into a flat hand and then drag the app to the bottom, or just swipe with touch interface. This part of the drap/swipe to snap and task swap. – rob May 17 '12 at 09:58

4 Answers4

8

From what I understand (watching Build2011 videos) a Metro App won't be able to do that...

Interaction between processes is severally limited to specific Contracts (the charms on the right: Search, Send-to).

Think Phone, not Desktop.

You might be able to build a non-Metro Win8 app though.

H H
  • 263,252
  • 30
  • 330
  • 514
8

To your specific question, this functionality is not available. Apps are not allowed to interact or interfere with other apps.

To answer your more general question, the APIs available to Metro style applications is limited compared to what is available to desktop applications. C# has a subset of the .Net library available, much like Silverlight does. The same is true for C++ where a subset of the desktop Win32/COM APIs are available.

Steve Rowe
  • 19,411
  • 9
  • 51
  • 82
  • 1
    i like this answer the best thus far, I guess I get the separation or the lack of that functionality. I just think moving forward, if all apps will be 'metro-style' that there will be some need to execute 'administrative tasks' beyond what is in the 'Tailored' .NET45 subset. I guess I can defer those tasks to a backing service. – Glenn Ferrie Oct 17 '11 at 01:16
  • 2
    For Windows 8, all apps won't be Metro style. There is a definite need for desktop apps still. IMHO, that may always be the case. I can't imagine Visual Studio or Photoshop (not elements) as a Metro style app. – Steve Rowe Oct 17 '11 at 03:48
  • 2
    Microsoft representatives (architects, managers, ..) have already stated that there are no plans to rid of desktop. That they simply see metro and desktop as two different usability scenarios. Somethings are easier with touch (mobile devices), and some things are better for desktop (precision). They have no plans to rid the desktop. It sounds like your app should be a desktop app and not a Metro one. Just because Metro is new does not mean its the right architecture and tool for the job. – David Anderson Apr 15 '12 at 04:50
3

Don't waste too much time on this. I expect that in a beta a close option (perhaps even a charm) will be included. Until then use a keyboard Alt-F4 or the Task Manager

Emond
  • 50,210
  • 11
  • 84
  • 115
  • 2
    Possible, but there's a lot of info about the app life cycle (suspend/deactivate) that does not require a close. You only really need a Close when an App hangs - and then a Close button won't work either. – H H Oct 16 '11 at 20:59
  • 1
    @HenkHolterman - unless it performs a 'Kill' like the TaskManager does. – Emond Oct 17 '11 at 04:33
  • 1
    But how do you tell it (a hanging app) to do that? – H H Oct 17 '11 at 05:49
  • 1
    We can't be Microsoft might add this functionality. – Emond Oct 17 '11 at 08:43
  • 1
    @HenkHolterman Presumably in the same way as close works on iOS: tell the process to close itself, and it it doesn't respond, then kill it. – Pavel Minaev Oct 17 '11 at 17:16
-1

C++:

Window::Current->CoreWindow->Close();

or

Window::Current->Close();

I haven't explored the difference between these two (more precisely, I don't know how CoreWindow differs from Current. I could assume though...

I'm using an Oracle VBox with Win8 on my Win7 machine to develop a C++ Metro App using VS 11. I used both of the above methods. I verified in Task Manager the app was not running on both Win8 and the Simulator.

AsusUltra
  • 1
  • 1