Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to Wait until the control Timer finish its task

How to Wait until the control Timer finish its task

How to Wait until the control Timer finish its task

I have a control Timer that executes its Timer Events 100 times. In other method I do the following:

CODE --> FoxPro

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.
&& 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.

RE: How to Wait until the control Timer finish its task

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 Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: How to Wait until the control Timer finish its task

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close