.NET 2中的多线程设计 [英] Multithread Design in .NET 2

查看:55
本文介绍了.NET 2中的多线程设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人们

我有一个关于多线程监视应用程序的设计问题.

I ve got a design question regarding an multithreaded monitoring application.

情况如下:

串行设备发送以CRLF结尾的行.由于警告问题,我必须缓冲传入的数据,并恢复/排队(xxxxxxxCRLF).没问题.

Serial Device sends lines ending with CRLF. Due to the caveeat problem I have to buffer incoming data and restore /enqueue it like (xxxxxxxCRLF) that. No problem at all.

之后,我必须解析排队的字符串.解析字符串所需的时间有所不同,通常比设备的发送频率长.

Afterwards Ive got to parse the queued strings. Time required to parse that strings varies and is usually longer than the device's sending frequency.

因此我想检索并解析排队的字符串ASYNC,以防止该队列溢出.

So Id like to retrieve and parse queued strings ASYNC preventing that queue to run over. 

最后,解析结果应再次排队,以进一步处理它们.必须按照与原始字符串相同的顺序将结果排入队列.

Finally the result of parsing should be queued again to process them further. Its necessary that the results are enqueued in the same order as the original strings.

我目前固定在.NET 2上,不知道如何正确正确地实现它.

Im currently pinned on .NET 2 and dont know how to implement it clean and correctly.

(没有ConcurrentQueue<>)

(No ConcurrentQueue<>)

我将不胜感激任何小费和/或一般性建议.

I'd appreciate any kind of tip and / or general advice.

非常感谢

Tobias Ehling

Tobias Ehling

P.S .:对于我的语言能力不足,我深表歉意

P.S.: I apologise for my insufficient language ability

推荐答案

Tobias

Hi Tobias

这听起来像可以通过一些轮询轻松实现,再加上 如链接所示,BackgroundWorker类在.net 2中都可用.

This sounds like something that could easily be achieved with some polling, plus the Queue Class and BackgroundWorker Class, both available in .net 2, as the links show.

线程类也可用于.net 2,您可以等待线程完成,例如 Thread.Join

The Thread Class is also available to .net 2, and you can wait for thread completion, like Thread.Join

 

此致,
皮特

Regards,
Pete


这篇关于.NET 2中的多线程设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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