04-12-2025, 07:39 AM
(This post was last modified: 04-12-2025, 08:03 AM by AbsoluteBeginner.)
Hello. 
First, you need to add a pause of about 50 milliseconds to the "While" loop.
I will continue to study the rest.
Secondly, your "OnButtonClicked" event handling routine does a lot of work.
Moreover, this subroutine calls the second subroutine, which waits for the third subroutine to execute.
I believe that before you start writing PROGRAM CODE, you should create a DIAGRAM that shows the PROGRAM LOGIC.
Programming is the process of CREATING the LOGIC of a future program.
Writing code is just CODING.

I suggest you create a diagram and start discussing it on our forum. When you see your diagram, then you can easily write the correct code.

First, you need to add a pause of about 50 milliseconds to the "While" loop.
I will continue to study the rest.
Secondly, your "OnButtonClicked" event handling routine does a lot of work.
Moreover, this subroutine calls the second subroutine, which waits for the third subroutine to execute.
I believe that before you start writing PROGRAM CODE, you should create a DIAGRAM that shows the PROGRAM LOGIC.
Programming is the process of CREATING the LOGIC of a future program.
Writing code is just CODING.

I suggest you create a diagram and start discussing it on our forum. When you see your diagram, then you can easily write the correct code.