我怎样才能让我的应用程序运行得更快 [英] How can I make my application run faster

查看:119
本文介绍了我怎样才能让我的应用程序运行得更快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个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屋!

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