控制班治疗从另一个班级进步

时间:2012-08-27 14:52:34

标签: c# queue

我希望我能成功解释。

我正在设计一个POC软件的控制台应用程序(概念证明),其功能最小化如下:

[Class 1]
1- Timer run each 60 seconds.
2- download an xml file over http (WebClient)
3- parse IDs (ID of metadata xml file inside the same http server)
4- Enqueue the queue by IDs in Class 2 [Queue<string> _downloadUrls = new Queue<string>()]
[Class 2 ]
5- Dequeue urls and start download each file whithin teh queue
6- Deserialize the xml to a valid reference an d save it into Database

问题:

如果Class2中的文件下载仍在进行中,我怎么能告诉Class1中的计时器逃脱处理(可能需要比Timer peridicity间隔更长的时间)。

N.B:下载是异步的。

此致

1 个答案:

答案 0 :(得分:0)

您仍然可以异步下载,但您应该将下载视为状态机...忙/空闲。

当你的计时器提出间隔事件时,检查机器是否有&#39;闲着如果是这样,请启动另一次下载。

......有意义吗?

相关问题