C# 带有延迟事件通知的作业队列实现
我正在寻找 .Net (3.5) 中现有的作业队列实现,我想知道是否有人对一个好的实现有建议。我认为没有作业队列能够完全满足我们的要求,因此我正在寻找一个可以轻松扩展的作业队列。
我们的基本要求:
- 需要能够并行或串行运行作业。有些作业可能必须串行完成,有些作业可能能够并行运行,即使这些串行作业正在运行。
(我想从技术上讲我们可以有 2 个作业队列,但基本实现仍然需要能够处理这两个队列。) - 需要能够让作业触发进度事件 - 但我们希望事件能够在准备好时触发,或者排队然后根据 UI 的轮询触发。
(我们希望所有事件都在主 GUI 线程中处理,因此在 GUI 更新时我们希望触发自上次更新以来发生的所有事件。)
谢谢,
利隆
I'm looking for an existing job-queue implementation in .Net (3.5) and I was wondering if anyone has suggestions for a good one. I assume that no job queue will be able to do exactly what we want, so I'm looking for one that can easily be extended.
Our basic requirements:
- Need to be able to run jobs in parallel or serial. Some jobs might have to be done serially, and some might be able to be run in parallel, even while those serial jobs are being run.
(I guess technically we could have 2 job queues, but the base implementation still needs to be able to handle both.) - Need to be able to have jobs fire up progress events - but we want to events to be able to fire either when they are ready, or to be queued up and then fired based on a poll from the UI.
(We want all the events to be processed in the main GUI thread, so on GUI update we are hoping to fire all events that have occurred since the last update.)
Thanks,
Liron
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
quartz.net 是一个非常全面的作业调度程序
quartz.net is a pretty comprehensive job scheduler
我已经做了一些类似的事情,它实际上只是一个消息队列,所以这里有一些关于基本实现的注释:
此外,我认为应该并行运行的作业实际上并不需要是作业 - 您可以在线程池上执行它们。
从这里,您可以设计定时执行(例如,应该在 10 秒后运行的作业)、迭代器的执行以及对公开 AsyncWaitHandler 的作业的支持(例如,允许其他作业在等待某些内容时执行)。
I've done some similar things, and it's really just basically a message queue, so here are some notes on a basic implementation:
Also, I think that jobs that should be run in parallel don't really need to be jobs - you can execute them on the ThreadPool.
From here, you can craft in timed execution (say, a job that should run 10 seconds later), execution of iterators, and support for jobs that expose an AsyncWaitHandler (e.g. allow other jobs to execute while it's waiting for something).