I managed to create the code to lock. I am sure that the code is to blame but is 100% sure to lock your board.
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using Microsoft.SPOT.Presentation.Media;
using System.Threading;
namespace MFWindowApplication1
{
public class Program : Microsoft.SPOT.Application
{
static Bitmap LCD;
static Font MyFont;
public static void Main()
{
MyFont = Resources.GetFont(Resources.FontResources.small);
LCD = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
LCD.Clear();
LCD.DrawText("Application lock 1", MyFont, Colors.Red, 10, 10);
LCD.Flush();
OutputPort Port1 = new OutputPort((Cpu.Pin)FEZ_Pin.Interrupt.IO19, true);
//This is the line that causes the app. to lock up
Port1.OnInterrupt += new NativeEventHandler(Port1_OnInterrupt);
Thread.Sleep(Timeout.Infinite);
}
static void Port1_OnInterrupt(uint data1, uint data2, DateTime time)
{
//throw new NotImplementedException();
}
}
}
This is a known issue, it is related to your code not using the OutputPort properly.
The events can ONLY be used with InterruptPort objects. Using it with OutputPort and with InputPort doesn’t make sense anyway and if you try to install an event handler you will simply crash the system!
Ideally you would get an exception if you tried to do that but what you are doing is wrong anyway