NoxiaZ
Posts: 11
Joined: Fri Jul 04, 2014 12:25 pm

Background Project

Mon Aug 24, 2015 7:46 pm

Hi Everyone,

I am trying to create an application that I call "KeepAlive" the function with this application is to detect if my main application called "Mekalink" is running, if the application is not running "KeepAlive" should start "Mekalink". Also the "KeepAlive" application have to job, making sure that "Mekalink" always can start, means if there are any settings that makes the program crash, it should reinstall the program.

All this i got to work on Linux, and now trying to create the same for Windows IoT, but I got a problem, I do not know how to detect which applications are running the OS, and I as well do not know how I can start "Mekalink" from "KeepAlive".

I am using the background core template project downloaded here: https://visualstudiogallery.msdn.micros ... 2624202d36

I hope that someone here can give me information about how to detect what applications are running, something like "System.Diagnostics.Process.GetProcesses()" in the .Net framework.

And how to start another application like "System.Diagnostics.Process.Start()" in the .Net framework.


//NoxiaZ

UndergroundFun
Posts: 44
Joined: Wed Jun 17, 2015 12:57 pm

Re: Background Project

Tue Aug 25, 2015 7:45 pm

I don't know how you would get the currently running processes, that seems to be one of the parts they left out under diagnostics.

You could add a check for a mutex in the application when it starts, to prevent multiple copies from running. Then add a scheduled task to try start the app periodically. So when the scheduled task fired it the application would just close itself if there was already an instance running.

Kind of kludgy, but I'm not sure how else to go about it with what's available.

This (Windows.System.Diagnostics.ProcessDiagnosticInfo.GetForCurrentProcess()) looks like you could detect if it was running. Not sure how you would fire it up if it wasn't though.

NoxiaZ
Posts: 11
Joined: Fri Jul 04, 2014 12:25 pm

Re: Background Project

Wed Sep 16, 2015 8:34 am

I couldn’t figure a way to do this correctly, so I came up with an idea using the Web interface for it instead.
I have attached my code, and hope it will help someone. – I will also be using this to install and uninstall apps on the pi, but the code have not been made yet.

I think the code explains it self, but feel free to ask if any questions.

Before anyone ask, I decided not use JSON.Net or anything else then simple parse of JSON by regex, to make sure there are no need for any third party library to make it work. (Also it gave me some problem in the core project using JSON parser.)
Attachments
ProcessHandler.zip
(1.87 KiB) Downloaded 45 times

Return to “Windows 10 for IoT”