Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Wait until the control Timer finish its task

Status
Not open for further replies.

Irwin1985

Programmer
Feb 2, 2017
44
0
0
ES
I have a control Timer that executes its Timer Events 100 times. In other method I do the following:
Code:
nTimes = 100
Timer1.Enabled = .T. && this enables the control Timer and its task begins. 
&& But in this line I need to wait until the timer finish its task.
I tried:
DO WHILE TaskFinishedFlag = .T.
ENDDO
&& But it doesn't work
&& Any idea? I was reading about AutoYield and DoEvents but don't know how to implement them.

A team is only pieces that you exchange until you finish the work, it is efficient, it works.
 
I'm not sure why you want to do this. In general, when a timer interrupts some other processing, that processing will always wait until the timer has finished before continuing. At least, that's my understanding.

If your TaskFinishedFlag is set to .T. within the timer, then it will still be true when the timer finishes, and therefore also when the DO WHILE loops starts, so the loop will always exit straight away. And that's assuming that TaskFinishedFlag is in scope in both the timer and your main code.

Also, the whole thing looks suspect because, by definition, you don't know what code is being executed when the timer fires. So you have no way of knowing where to put your "wait for timer to finish" code.

Or have I completely misunderstood your scenario?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
In very short: Your code doesn't tell why it's not working. The core waiting loop you have addressed a variable your code does not declare or set.

From your description, I'd expect that waiting loop to wait for the timer to have decreased the nTimes to 0. I can only guess the Timer would then set TaskFinishedFlag = .T.

But you don't wait until that happens, your loop waits WHILE TaskFinishedFlag = .T. If TaskFinishedFlag is initialized to .F. in some code you don't show us, your loop does not wait at all, the WHILE condition would then not be fulfilled, and so the loop never even starts.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top