CPU efficiant thread when polling for updates.

  • 13 years ago

    Hi all,

    I have a problem I'm not sure how to solve.

    I have an application that will spawn multiple worker threads (non thread-pool) that needs to know when jobs are added to a queue in SQL server 2005.  Now the neat solution would be to use AutoResetEvents when the data is updated.  The problem is the data is updated from a completely different application (out of process code).

    If I use a polling mechanism things are going to get hairy.  I cannot have several threads polling the DB at the same time I guess it will just kill the DB.  What can I do here?  Anyone have any advice?  Would I need to have one thread polling the DB and signalling the threads that want to know?  Problem is that gets complicated.  Can I somehow signal the threads from an outside process.  Problem is the code is not .NET so COM interop is the only way (ah, nightmare)

    Is there any other way I can do this kind of polling in a CPU friendly way?  Is there a wait mechanism available that I have missed?

    TIA

    Richard

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“XML is like violence - if it's not working for you, you're not using enough of it.”