.Net 中的大容量、高速文本框

发布于 2024-10-04 20:22:57 字数 673 浏览 0 评论 0原文

我正在编写一个应用程序,它将以高达 250kb/秒 的速率显示串行/USB 数据。我正在使用 .net SerialPort 类并对 DataReceived 事件做出反应。对于该软件的早期实现,我只是将传入数据存储在 WinForms RichTextBox 中。此解决方案工作正常,直到控件中有50k - 100k 行,此时应用程序陷入困境。从那时起,我尝试使用 WPF 实现我的目标,但发现了同样的问题。我曾尝试在文本框中仅保留当前可见的文本,并将其余内容存储在大型List中但这个解决方案需要大量的解决方法,最终被放弃 - 我不想重新发明轮子

现在我来找你是为了一线希望 - 我愿意尝试任何事情!我应该使用自定义控件(欢迎付费和免费控件)? SQLite?如上所述虚拟化?我应该尝试轮询串行端口而不是对事件做出反应吗?

I am writing an application that will display serial/USB data at a rate of up to 250kb/sec. I am using the .net SerialPort class and reacting to the DataReceived event. For early implementations of this software, I simply stored the incoming data in a WinForms RichTextBox. This solution works fine until there are 50k - 100k lines in the control, at which point the application bogs down. Since then, I've tried accomplishing my goals with WPF and found the same problem. I tried, at one point, to keep only the currently visible text in the textbox, and store the rest in a large List<string> but this solution required a huge number of workarounds and, in the end, was abandoned - I'd rather not reinvent the wheel.

Now I come to you for a thread of hope - I am willing to try anything! Should I use a custom control (both pay and free controls are welcome)? SQLite? Virtualization as described above? Should I try polling the SerialPort instead of reacting to events?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

り繁华旳梦境 2024-10-11 20:22:57

使用线程读取数据并直接写入文件。让您的应用经常刷新文件中的最后 x 行。也许甚至可以根据阅读器线程的通知进行刷新?

通过使用多个线程,您将保持 UI 的响应能力,并且通过直接写入文件,您将确保您已收集了所有数据。此外,它还允许您暂停显示足够长的时间,以便在继续捕获数据的同时实际复制/粘贴您想要的数据。

也许您可以实现自己类型的文件阅读器,该阅读器允许用户通过仅加载您可以一次实际在屏幕上显示的部分来“滚动”文件。

Use a thread to read the data and write it directly to a file. Have your app refresh the last x number of lines from the file every so often. Maybe even have the refresh based off of a notification from the reader thread?

By using multiple threads you'll keep the UI responsive and by writing straight to a file you'll ensure you've collected all of the data. Also, it will allow you to pause the display long enough to actually copy/paste the data you want while continuing to capture data.

Possibly you could implement your own type of file reader that would allow the user to "scroll" through the file by only loading the parts you can actually display on screen at one time.

非要怀念 2024-10-11 20:22:57

如果数据主要是面向行的(ReadLine),则将其放入列表框中。它是在屏幕上放置大量文本的最快控件。

但您会发现所有 UI 控件都是针对人类交互,而不是针对端口的速度。最好的办法是重新考虑你的设计。这些数据到底有什么用呢?

If the data is largely line oriented (ReadLine) then put it in a ListBox. It is the fastest control for putting lots of text onscreen.

But you will find that all UI controls are geared toward human interaction, not to the speed of a Port. Best thing to do would be to rethink your design. What is that data for anyway?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文