Reply To: Rubik's cube solver

HomeForumsMonoBrick EV3 FirmwareRubik's cube solverReply To: Rubik's cube solver

#5157
Author Image
Anders Søborg
Key Master

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

Posted in

Make a donation