synchronize threads - no UI
Posted
by UshaP
on Stack Overflow
See other posts from Stack Overflow
or by UshaP
Published on 2010-03-17T15:16:47Z
Indexed on
2010/03/17
15:31 UTC
Read the original article
Hit count: 216
I'm trying to write multithreading code and facing some synchronization questions. I know there are lots of posts here but I couldn't find anything that fits.
I have a System.Timers.Timer
that elapsed every 30 seconds it goes to the db and checks if there are any new jobs. If he finds one, he executes the job on the current thread (timer open new thread for every elapsed). While the job is running I need to notify the main thread (where the timer is) about the progress.
Notes:
- I don't have UI so I can't do
beginInvoke
(or use background thread) as I usually do in winforms. - I thought to implement
ISynchronizeInvoke
on my main class but that looks a little bit overkill (maybe I'm wrong here). - I have an event in my job class and the main class register to it and I invoke the event whenever I need but I'm worrying it might cause blocking.
- Each job can take up to 20 minutes.
- I can have up to 20 jobs running concurrently.
My question is:
What is the right way to notify my main thread about any progress in my job thread?
Thanks for any help.
© Stack Overflow or respective owner