Main Site Documentation

NETMF Applications Install (FULL)


#1

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.


#2

Thanks, Skewworks!

In case anyone doesn’t understand what this is, check out this project I built using this framework a couple years ago. It’s very easy to use and works wonderfully.

https://www.ghielectronics.com/community/forum/topic?id=8346


#3

I’ve just updated the install. Yes, already.

I decided to add a PersistableObject collection. This way if you have other singletons that need to be persisted across domains you can simply add their instance to the ApplicationManager and when they’re called from a new AppDomain they can recognize they’re not under default and grab their instance there.

ApplicationManager.AddPersistableObject(object obj, string name)
and
ApplicationManager.GetPersistableObject(string name)


#4

I always been surprised when Skewworks is posting stuff. It looks like its from another planet. In a good way :hand:


#5

I think this quote needs to go on my business cards. Skewworks code, it looks like its from another planet…in a good way. :smiley: :smiley: :smiley:


#6

I am curious. How did you came up with the name “Skewworks”?


#7

Skewworks didn’t start off as a company. It actually started as my personal blog many, many years ago. I used it to post code, thoughts, etc. Skew coming from “suddenly change direction or position” reflecting the all over the grid nature of my postings and works, obviously.

When I started with Arduino and then NETMF everything was posted on the Skewworks blog. It got popular enough that when it came time to actually start selling off some of the code I kept the name because people knew it.

On the whole, not a great name and I have difficulty getting people to say/spell it correctly. But what can you do? One day, I may change it.


#8

@ Skewworks - Cool. I find it interesting how people come up with names.

Today it is highly dependent on the availability of the same domain name.