enghsiang: i have more then 1 console that will read the event list that store at db table. once the event is trigger, the flag will be update so that other console wont read the event again. but it do happen that 2 console is reading the same event at the same time and doing duplicated work.
any idea how to prevent this?
This is concurrency and it depends where its this code that checks for the flag/trigger?
Is this a common service that is consumed by both the console applications, or is it within the console application itself.
Basically, depending where the first central point is, that is where you need to lock the thread/or set up a transaction.
Therefore, if the code is in a central service you can use .NET transactions to manage this behaviour or use your SQL to manage the transaction.