如何在处理巨大任务的同时使Windows窗体对用户的交互负责? [英] How Can I Make The Windows Form Responsible To Users' interaction While It Processes A Huge Task?
本文介绍了如何在处理巨大任务的同时使Windows窗体对用户的交互负责?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友。
我写了一个耗费大量工作的程序。这项工作的结果显示在RichTextBox中。在处理工作时,程序不起作用。
我想在RichTextBox中显示结果,程序负责鼠标点击,最小化,...
我怎么能这样做?
谢谢。
Hi friends.
I write a program that does a time consuming work. the results of this work is shown in a RichTextBox. The program does not act while the work is processed.
I want to show the results in RichTextBox and the program be responsible for mouse click, minimizing,..
how can i do this?
Thanks.
推荐答案
简单:移动巨大的任务到BackgroundWorker,并使用进度报告更新RichTextBox。
这样,UI线程可以自由地做任何需要的事情,包括响应用户鼠标点击!
自由软件管理工作原理en-us / library / system.componentmodel.backgroundworker(v = vs.110).aspxtarget =_ blanktitle =New Window> ^ ] - 该链接包含一个示例。
Simple: Move the "huge task" to a BackgroundWorker, and use the progress report to update the RichTextBox.
That way, the UI thread is free to do anything it needs to, including respond to the user mouse clicks!
https://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(v=vs.110).aspx[^] - the link includes an example.
这篇关于如何在处理巨大任务的同时使Windows窗体对用户的交互负责?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文