我怎样才能让我的应用程序运行得更快 [英] How can I make my application run faster
问题描述
我建立一个Windows窗体应用程序,而我处理一个庞大的数据库,所以我必须使用许多循环与我的表工作。我使用C#语言
,问题是在处理过程中的程序过程数据的应用程序滞后和时间要求来处理我的数据是不能接受的。
I'm building a windows forms application, and I'm processing a huge database, so I have to use many loops to work with my tables. I'm using C# language, the problem is when the program process data the application lag during the processing and the time require to process my data is not acceptable.
推荐答案
那么,如果你使用的是C#语言,
首先防止滞后的问题;使用一个任务:
Well if you are using C# language, First to prevent the lag issue; use a Task:
Task task = Task.Factory.StartNew(() =>
{
//put you code here
});
和for循环,您可以使用它具有和foreach Parallel类。
如果你需要修改的东西你可以使用下面的代码的GUI:
and for loops you can use Parallel class it has for and foreach. if you need to modify something in the GUI you can use the following code:
this.Invoke((MethodInvoker)delegate
{
//you code
});
和有其他的方法,通过创建线程或研究背景的工人...
and there are other ways by creating threads or backgroud workers...
这篇关于我怎样才能让我的应用程序运行得更快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!