Exemplo n.º 1
0
        public void Spin(CancellationToken cancel = default(CancellationToken))
        {
            Logger.LogInformation("Start spinning");
            while (ROS.OK)
            {
                callbackQueue.CallAvailable(ROS.WallDuration);

                if (cancel.IsCancellationRequested)
                {
                    break;
                }

                Thread.Yield();
            }
        }
Exemplo n.º 2
0
        public void Spin(CancellationToken token)
        {
            TimeSpan wallDuration = new TimeSpan(0, 0, 0, 0, ROS.WallDuration);

            Logger.LogInformation("Start spinning");
            while (ROS.OK)
            {
                DateTime begin = DateTime.UtcNow;
                callbackQueue.CallAvailable(ROS.WallDuration);

                if (token.IsCancellationRequested)
                {
                    break;
                }

                DateTime end           = DateTime.UtcNow;
                var      remainingTime = wallDuration - (end - begin);
                if (remainingTime > TimeSpan.Zero)
                {
                    Thread.Sleep(remainingTime);
                }
            }
        }