由网友(奡雪)分享简介:我写一个多线程服务,拿起作业过程中,有1(未处理)状态。一旦他们被拾起,我需要那些行的状态更改为2(表示正在进行中),这样另一个线程(即在几秒钟内生成)不拿起这些行进行处理。I am writing a multithreaded service that picks up jobs to process that...
我写一个多线程服务,拿起作业过程中,有1(未处理)状态。一旦他们被拾起,我需要那些行的状态更改为2(表示正在进行中),这样另一个线程(即在几秒钟内生成)不拿起这些行进行处理。
I am writing a multithreaded service that picks up jobs to process that has the status of 1 (unprocessed). As soon as they are picked up, I need to change the status of those rows to 2 (indicates In Progress) so that another thread (that is spawned within a few seconds) does not pick up these rows for processing.
有关选择,我会做这样的事情:
For select, I would do something like this:
var jobs = from j in db.Jobs
where j.Status == 1
select j;
我如何重写这个更新行,并选择它们在同一时间?
How do I rewrite this to update the rows and also select them at the same time?
推荐答案
使用交易的。还有它是如何工作这里。
Use a transaction. There are some examples of how it works here.
相关推荐
最新文章