0

this is a part of a program is for a robot it have to go to a specific point after some time to another ecc A->delay->B->delay->C

the problem is that the program does this delay->delay->delay->Last

this is the part of the program

  Thread.Sleep(200);
            IK(10, 10);
            Draw(Theta1, Theta2);
            Thread.Sleep(200);
            IK(11, 11);
            Draw(Theta1, Theta2);
            Thread.Sleep(200);
            IK(12, 12);
            Draw(Theta1, Theta2);
            Thread.Sleep(200);
            IK(13, 13);
            Draw(Theta1, Theta2);
            Thread.Sleep(200);
            IK(14, 14);
            Draw(Theta1, Theta2);
            Thread.Sleep(200);
            IK(15, 15);
            Draw(Theta1, Theta2);
            Thread.Sleep(200);
            IK(16, 16);
            Draw(Theta1, Theta2);
            Thread.Sleep(200);
            IK(17, 17);
            Draw(Theta1, Theta2);
            Thread.Sleep(200);
            IK(18, 18);
            Draw(Theta1, Theta2);
            Thread.Sleep(200);
            IK(19, 19);
            Draw(Theta1, Theta2);
            Thread.Sleep(200);
            IK(20, 20);
            Draw(Theta1, Theta2);

here i have an example of what the program does

 Thread.Sleep(200);
 Thread.Sleep(200);
 Thread.Sleep(200);
 Thread.Sleep(200);
 Thread.Sleep(200);
 Thread.Sleep(200);
 Thread.Sleep(200);
 Thread.Sleep(200);
 Thread.Sleep(200);
 Thread.Sleep(200);
 Thread.Sleep(200);
 IK(20, 20);
 Draw(Theta1, Theta2);

so the robot go only to the last point after all the time is passed

using c# & wpf

draw function

        public void Draw(double a,double b)
        {
            //a=t1 b=t2

            linea1.X2 = (Math.Cos((Math.PI / 180) * a)) * 100;
            linea1.Y2 = (Math.Sin((Math.PI / 180) * a)) * 100;

            linea2.X2 = (Math.Cos((Math.PI / 180) * b)) * 100;
            linea2.Y2 = (Math.Sin((Math.PI / 180) * b)) * 100;

            linea3.X2 = linea1.X2;
            linea3.Y2 = linea1.Y2;
            linea4.X1 = linea3.X2;
            linea4.Y1 = linea3.Y2;

            linea4.X2 = (Math.Cos((Math.PI / 180) * (b + a))) * 100 + linea1.X2;
            linea4.Y2 = (Math.Sin((Math.PI / 180) * (b + a))) * 100 + linea1.Y2;

        }

  • https://stackoverflow.com/questions/37787388/how-to-force-a-ui-update-during-a-lengthy-task-on-the-ui-thread ... may help. – Neil W Aug 04 '22 at 11:30
  • you added [timer] tag. that is what you should use - a timer - and move robot on each tick. as the last resort, chech this: https://stackoverflow.com/questions/20082221/when-to-use-task-delay-when-to-use-thread-sleep – ASh Aug 04 '22 at 11:30
  • Please provide with your Draw() method Also, how do you state it dors this ? Output logging, other ? – Romka Aug 04 '22 at 11:31
  • i edited no you can se the draw function that modify the coordinates of lines in a wpf canvas – gino pasticcio Aug 04 '22 at 11:47
  • You should take a look at animations. You can create a Storyboard that comprises all the animation steps – BionicCode Aug 04 '22 at 11:52
  • thx so i do animation in wpf ? – gino pasticcio Aug 04 '22 at 12:15
  • [Animation Overview](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/graphics-multimedia/animation-overview?view=netframeworkdesktop-4.8) – BionicCode Aug 04 '22 at 13:47

0 Answers0