views:

36

answers:

2

I have a widows service that is scheduled to run every hour or so. It basically calls a static method in a referenced assembly.

My concern is that the method wont finish running during the hour period, so if it is overlapping it will cause some problems, im using lock statement around the method body.

my question is this... will the method called start a new process every hour, and if so, will the lock statement work across processes?

A: 

It sounds like you're using the windows scheduler to kick off your task. You might be better off making it a full Windows Service, then you've got a lot more control of when you get invoked.

Andrew
i am using a windows service already, i can control how often it gets called, i just want to make sure they dont overlap
wcpro
A: 

If you need synchronization across processes, you should use a mutex. I am not sure if your code will launch a new process every hour, need more information about what you are doing.

Segfault
im building a piece of software that process a batch of subscriptions every x minutes. The windows service just calls a static method ProcessSubs from a referenced assembly, this method uses lock and will basically iterate through the subscription records that have been flagged for processing
wcpro
in that case, lock is sufficient for your needs.
Segfault