【问题标题】:Do action until specific time in C# [closed]在C#中执行操作直到特定时间[关闭]
【发布时间】:2014-08-06 16:22:32
【问题描述】:

我正在尝试开发一个运行电机的 Windows Phone 应用程序。我只想执行 MoveCar 方法 1 秒,然后执行 Stop

我有这段代码可以正确移动 C 电机:

CarControl _cc;    
private void UP_Motor_C(object sender, RoutedEventArgs e)
    {
        _cc.Turn = 50; //the C motor will start running in 50% speed
        _cc.LeftSpeed = 0; //the B motor will stop working
        _cc.RightSpeed = 0; //the A motor will stop working

        _cc.MoveCar();
    }

我的问题是我缺少启动 MoveCar 的代码,仅持续一秒钟。实现我想要的最佳方式是什么?

【问题讨论】:

  • 我猜 NXT 框架中有一些东西可以为你做到这一点......
  • 索要代码但不努力会让你被否决。
  • 欢迎来到 Stackoverflow!在移动一秒钟然后停下来之前先看看游览! stackoverflow.com/tour

标签: c# time nxt


【解决方案1】:
    _cc.Turn = 50; //the C motor will start running in 50% speed

    _cc.LeftSpeed = 0; //the B motor will stop working
    _cc.RightSpeed = 0; //the A motor will stop working

    _cc.MoveCar();

    System.Threading.Thread.Current.Sleep(1000);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-03
    • 2015-11-13
    • 2013-08-05
    • 1970-01-01
    • 2012-03-15
    相关资源
    最近更新 更多