Hi,
My problem is that i want to close the program instantly when the “Escape” Button on the EV3 is pressed(even if its in a while-loop or something similar)… My current code looks like this:
using System;
using MonoBrickFirmware;
using MonoBrickFirmware.Movement;
using MonoBrickFirmware.Display;
using MonoBrickFirmware.Sensors;
using MonoBrickFirmware.UserInput;
using System.Threading;
namespace ColorSensorExample
{
class R_Main
{
public static void Main (string[] args)
{
R_Main main = new R_Main ();
}
public R_Main()
{
var sensor = new EV3ColorSensor (SensorPort.In2);
ButtonEvents buts = new ButtonEvents ();
buts.EscapePressed += new Action(onEscape);
while (true)
{
//Main-Code
}
}
private void onEscape()
{
EventWaitHandle stopped = new ManualResetEvent (false);
stopped.Set ();
}
}
}
But it does not work. While using the “KeyTest”-Example from the Monobrick Homepage, there is no problem.
Follow