Jump to content
MarkShark

Correct way to use WaitFor with a background worker.

Recommended Posts

I have a background worker that I create with:

  FWorker := Parallel.BackgroundWorker
    .NumTasks(1)
    .Execute(HandleQueryWorkItem);

I queue jobs to this worker and everything works great .  I have a situation where I want to check if the worker is idle with a timeout, so I'm trying to use:

FWorker.WaitFor(MyMilliseconds);

This seems to work in my test cases, however calling WaitFor calls "CompleteAdding" (which seems to make sense.)  However it never gets turned back on and future queueing of jobs raises "Adding to completed collection".

 

So is there a way to turn queueing back on, or am I doing something fundamentally wrong?   Thanks for any insight or tips!

 

-Mark

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×