多个连接和多个UI [英] Multiple Connections and multiple UI for them

查看:63
本文介绍了多个连接和多个UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,所以我一直在忙这个问题,我说从串行端口接收多个数据包,每个数据包都有唯一的标识符.我想做的是让每个ID在差异窗口中打开,同时处理数据以及所有可用的用户交互,例如按钮单击和填充.

我在这里很挑剔,如果没有解决方案,我可以做无聊的事情,对不同的ID进行排序,然后打开多个线程在后台进行工作,然后在完成工作后显示它.

到目前为止,我已经阅读了有关MDI的文章,但不确定如何帮助我.为每个新标识符打开一个新表格?不知道我是否读错了,但是他们在论坛上说,创建第二个表单的基础表单一直等待到完成第二个表单为止.这是正确的吗?

任何建议将不胜感激.

谢谢

Ok so I''ve been busy on this problem, I''m receiving lets say multiple packets from the serial port, each with unique identifiers. What I want to do is have each ID open up in a diff window concurrently processing data along with all user interactions available, like button clicks and stuff.

I''m being quite picky here, if there is no solution I could do the boring thing and sort the different ID''s and then open up multiple threads to do the work in the background, and then after the work is done display it.

So far I''ve read about MDI''s, but not sure how that helps me. Opening up a new form for every new identifier perhaps? Not sure if I read wrong, but in a forum they said that the base form, from where the Second form is created waits until the Second form is done. Is this correct.

Any suggestions will be greately appreciated.

Thanks

推荐答案

刚刚发现了这个多个SDI应用程序,
Just found this Multiple SDI applications, http://en.csharp-online.net/Application_Architecture_in_Windows_Forms_2.0%E2%80%94Multiple-SDI_Applications[^], is this good or bad??


您的UI应该全部集中在一个线程中(如果不是这样,则会发生奇怪的事情).创建多个表单很简单,尽管出于可用性考虑,您可能想重新考虑(例如制作选项卡式界面或使用MDI).

只有一个串行端口,对吗?我不明白您为什么要为每个ID分配一个线程.取而代之的是,有一个线程正在侦听并将消息分派到适当的消息处理程序,该线程然后可以对其执行任何操作并更新其UI.
Your UI should all be in one thread (weird things happen if that''s not the case). It''s trivial to create multiple forms, though you might want to reconsider that for usability reasons (for example making a tabbed interface or using MDI).

There is only one serial port, right? I don''t understand why you want a thread for each ID. Instead, have one thread which is listening and dispatches messages to the appropriate message handler, which can then do whatever with it and update its UI.


要同时激活多个对话框,您将需要无模式地创建和打开它们.并且一旦您这样做,它们中的每个都应使用后台线程进行进一步处理.

您也可以考虑使用Task Parallel库,但是在您的特定情况下可能有些棘手.我想仍然可行.但是我个人只是选择简单的线程解决方案.
For having multiple dialogs active at the same time, you would need to create and open them modelessly. And once you do that each of them should use a background thread to do further processing.

You could consider using the Task Parallel library too but it may be kinda tricky in your specific scenario. Still doable I''d think. But I''d personally just go with the simple thread solution.


这篇关于多个连接和多个UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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