Dispose() public méthode

public Dispose ( ) : void
Résultat void
Exemple #1
0
        private void Run(string[] args)
        {
            // Creating this from static causes an exception in Raspian. Not in ubunti though?
            Log  = LogManager.GetCurrentClassLogger();
            var options = new ConsoleOptions(args);

            if (options.ShowHelp)
            {
                Console.WriteLine("Options:");
                options.OptionSet.WriteOptionDescriptions(Console.Out);
                return;
            }

            var deviceFactory = new Pca9685DeviceFactory();
            var device = deviceFactory.GetDevice(options.UseFakeDevice);
            var motorController = new PwmController(device);
            motorController.Init();

            Log.InfoFormat("RPi.Console running with {0}", options);

            switch (options.Mode)
            {
                case Mode.DcMotor:
                    RunDcMotor(motorController);
                    break;

                case Mode.Servo:
                    RunServo(motorController);
                    break;

                case Mode.Stepper:
                    motorController.Stepper.Rotate(600);
                    break;

                case Mode.Led:
                    RunLed(motorController);
                    break;

                case Mode.RawPwm:
                    RunRawPwm(device);
                    break;

                case Mode.AlarmClock:
                    var alarmClock = new AlarmClock(motorController);
                    alarmClock.Set(options.AlarmDate);
                    alarmClock.WaitForAlarm();
                    break;

                case Mode.SignalRTest:
                    var signalRConnection = new SignalRConnection(motorController);
                    signalRConnection.Run();
                    break;
            }

            motorController.AllStop();
            deviceFactory.Dispose();

            //http://nlog-project.org/2011/10/30/using-nlog-with-mono.html
           // NLog.LogManager.Configuration = null;
        }