For a few years my one closely guarded secret was how I managed applications over multiple domains. I opened up the interfaces about 2 years ago but I still didn’t give away how to have a single source for knowing, activating and terminating the applications.
Well, here it is. This assembly will give you everything you need to robustly manage applications over multiple domains.
http://skewworks.com/downloads/netmf/netmf_apps.exe, also requires: http://skewworks.com/downloads/netmf/netmf_ext.exe
ApplicationManager is a singleton that persists a single instance reference across all domains and refused to let anything other than the default domain create it (using ApplicationManager.Initialize();).
Launching an application is as simple as calling ApplicationManager.LaunchApp();. You can activate and terminate applications as well.
A new EX7 class (complete with application to convert PEs to EX7s) allows you to grab icons and information from the file without having to first shell it. This saves time and resources.
So, the request question is, how simple is it to make a NETMF application you can launch? Well here’s the code for a small app created as a Class Library with references to: Skewworks.NETMF.TypeClasses and Skewworks.NETMF.Applications:
using System;
using System.Threading;
using Microsoft.SPOT;
using Skewworks.NETMF;
using Skewworks.NETMF.Applications;
namespace DemoApplication
{
// Applications MUST be serializable or they will FAIL
[Serializable]
public class Class1 : NETMFApplication
{
#region Properties
public override ApplicationDetails ApplicationDetails
{
get
{
return new ApplicationDetails("Demo Application", "NETMFApplication demo", "Skewworks, Inc.", "(C)2015", "v1.0");
}
}
public override ApplicationImage ApplicationImage
{
get
{
return new ApplicationImage(null, new Size(0, 0), ImageType.Native);
}
}
#endregion
#region Application Methods
public override void Activate()
{
Debug.Print("Hey! I was activated, that means another application had focus first, and I took it!");
}
public override void Blur()
{
Debug.Print("Aw man, I'm losing focus. I should suspend my activities");
}
public override void Main()
{
Debug.Print("Hello world!");
Thread.Sleep(3000);
Debug.Print("Well, better terminate myself");
ApplicationManager.TerminateApplication(this.ThreadId);
}
public override void Terminating()
{
Debug.Print("Hey! Hey, you! I'm being terminated. Clean up any active code or it will be auto terminated in 5 seconds");
}
#endregion
}
}
But what if you have dependencies? Yeah, those are automatically loaded for you. Include any PEs you need in the same directory and in the go. Dependencies already in the default domain? They get loaded too.