Home→Forums→MonoBrick EV3 Firmware→Rubik's cube solver→Reply To: Rubik's cube solver
December 30, 2014 at 12:15
#5157

Anders Søborg
Keymaster
Hi Again
Sorry if I was not clear enough on the poll thing. In your main program which looks like this:
static class Program
{
static void Main(string[] args)
{
var terminateProgram = new ManualResetEvent(false);
var cubeSolver = new CubeSolver();
var buts = new ButtonEvents();
buts.EscapePressed += () => terminateProgram.Set();
Task.Factory.StartNew(cubeSolver.Run);
terminateProgram.WaitOne();
cubeSolver.Stop();
//var solution = Search.solution(Tools.randomCube(), 26, false);
}
}
you create a ButtonEvents() so you can terminate the program. This will create a thread that polls for changes very 50 ms – so if your program uses a lot of threads your program might end up spending time switching threads instead of doing actual calculations. Anyway you can have a look at what the ButtonEvent class does here, but when you described what you program is actually doing it does not sound like this is really an issue -:)
/Anders
Follow