设计:队列管理问题(C#) [英] Design: Queue Management question (C#)

查看:138
本文介绍了设计:队列管理问题(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个窗口服务,将使用远程编码服务(如encoding.com,禅宗codeR等)上传视频文件进行编码,将它们下载后的编码过程已经完成,过程它们。

I want to build a windows service that will use a remote encoding service (like encoding.com, zencoder, etc.) to upload video files for encoding, download them after the encoding process is complete, and process them.

为了做到这一点,我在想有不同的队列,一个用于处理当前正在等待文件,一个文件被上传,一个用于文件等待编码完成,并多了一个用于下载。每个队列有一个限制,例如仅5个文件可以在一定的时间上载用于编码。该队列必须是看得见的,能够从崩溃中复活 - 目前我们做到这一点通过写队列SQL表和管理在一个单独的表项数

In order to do that, I was thinking about having different queues, one for handling currently waiting files, one for files being uploaded, one for files waiting for encoding to complete and one more for downloading them. Each queue has a limitation, for example only 5 files can be uploaded for encoding at a certain time. The queues have to be visible and able to resurrect from a crash - currently we do that by writing the queue to an SQL table and managing the number of items in a separate table.

我也希望队列在后台运行,相互独立的,但能够从一个队列的过程中传输文件到另一个不胜枚举。

I also want the queues to run in the background, independent of each other, but able to transfer files from one queue to another as the process goes on.

我的最大的问题是如何建立的队列和管理它们,而较少有关限制每个队列中的项目数。

My biggest question mark is about how to build the queues and managing them, and less about limiting the number of items in each queue.

我不知道什么是正确的做法,这和倒很AP preciate任何帮助。
谢谢!

I am not sure what is the right approach for this and would really appreciate any help.
Thanks!

推荐答案

您可能并不需要的工作分成不同的队列,只要以某种方式在逻辑上是分开的(标记为不同的工种或这样的)。

You probably don't need to separate the work into separate queues, as long as they are logically separated in some way (tagged with different "job types" or such).

在我看来,面临的挑战是不接,处理更多的比从队列中的作业给定数量有限,基于作业类型。我有一个有点类似的问题,前一段时间而导致<一个href="http://stackoverflow.com/questions/1496576/design-pattern-managing-a-limited-number-of-a-resource">question在这里SO 和随后的博客文章与我的解决方案,这两者可能给你一些想法。

As I see it, the challenge is to not pick up and process more than a given limited number of jobs from the queue, based on the type of job. I had a somewhat similar issue a while ago which led to a question here on SO, and a subsequent blog post with my solution, both of which might give you some ideas.

总之我的解决方案是,我把令牌的名单。当曾经我想执行有某种限制的工作,我第一次拿起令牌。如果没有标记可用,我将需要等待一个变得可用。然后,你可以使用任何排队合适的机制来处理队列如此。

In short my solution was that I keep a list of "tokens". When ever I want to perform a job that has some sort of limitation, I first pick up a token. If no tokens are available, I will need to wait for one to become available. Then you can use whatever queueing mechanism suitable to handle the queue as such.

这篇关于设计:队列管理问题(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆