当前注册人数162855人 邮箱: 密码: 注册新用户 忘记密码
首页 C/C++/MFC C# ASP.NET VB.NET MATLAB   站内搜索 BBS讨论社区 下载代码说明/积分规则
为什么要注册?

1. 可以直接免费从本站下载代码,防止邮件发送不到您的邮箱,或登录不了国外网站

2. 可以设定关键字,当有您关心的代码收录时,邮件通知您

3. 对这里的代码进行评分和评论

4. 可以和大家一起分享你的源代码,得到更多的建议

An Alternate Way of Writing a Multithreaded GUI in C#

C#中最快速的多线程界面操作源代码

2007年12月09日
C# (C# 1.0, C# 2.0, C# 3.0), .NET (.NET 3.5, .NET 3.0, .NET 1.0, .NET 1.1, .NET 2.0, Mono, DotGNU), WinForms, Dev
本程序不是采用通用的InvokeRequired(), BeginInvoke() 和 EndInvoke()在多线程中操作界面控件,而是直接在线程中操作,这样避免了不必要的线程切换操作,达到最快速的更新速度。
相关知识

最核心代码:

private void theMainForm_Load(object sender, EventArgs e)
        {
            // Prevent the framework from checking what thread the GUI is updated from.

            theMainForm.CheckForIllegalCrossThreadCalls = false;

            // Create our worker threads and name them. 

            // The name will be used to associate a thread with a specific ListBox.

            worker1 = new Thread(new ThreadStart(UpdateListBox));
            worker1.Name = "Worker1";

            worker2 = new Thread(new ThreadStart(UpdateListBox));
            worker2.Name = "Worker2";

            worker3 = new Thread(new ThreadStart(UpdateListBox));
            worker3.Name = "Worker3";

            worker4 = new Thread(new ThreadStart(UpdateListBox));
            worker4.Name = "Worker4";

            // Get all the threads running.

            Start();
        }
源代码原文下载:
An Alternate Way of Writing a Multithreaded GUI in C# This article outlines an alternate method of writing a responsive multithreaded Windows Forms GUI in C#. When I say "alternate," I mean a technique that does not follow the current Microsoft mantra that only the thread that created a GUI control should interact with it. Provided that care is taken to enforce that only the thread associated with a particular control is allowed to update it, then this technique can produce an extremely fast and responsive GUI. An additional benefit can be seen in the simplification of the code, as no calls to InvokeRequired(), BeginInvoke() or EndInvoke() are required. In addition, the performance overhead of marshaling calls onto the GUI thread has also been removed. If speed in the Windows Forms GUI is your top priority, you might want to give this technique a try.

源码图片

从本站下载附件及源代码(1个附件,已经成功下载681次)

最值得关注的外文源代码

An Alternate Way of Writing a Multithreaded GUI in C#
Very fast table copy from an ODBC source into MS Access within a C# project
Fast List Data Structure Source Code
Fast Image Rotation For .NET Compact Framework
评论(评论是增加积分的一个有效途径)
字数在300字内
请如实评论
本源代码共评论171次,此处显示最近20次评论! 查看所有评论

love419  2010年06月29日
恩,辛苦了!
tt  2010年03月22日
不错
wdsimon  2010年03月20日
不错啊
jine1987  2009年12月05日
学习学习
zzcodesou  2009年11月27日
属于入门级代码,也不错!
alias  2009年11月27日
C#中最快速的多线程界面操作源代码
shirley  2009年10月27日
我怎么下的是.axsp格式的啊
lz  2009年10月21日
最近学乱套了..我做的项目需要大量的用线程.. 看看
xieyong_198510  2009年08月21日
我正在学习多线程。谢谢分享。
半匹狼  2009年08月10日
很好,原来低于14分时不可以下载的啊。
dane  2009年08月08日
学习下。
qiqi  2009年07月11日
源码搜搜真好,学习了
huazctstyj  2009年07月02日
haohao
joneoboe  2009年06月24日
学习,现在源码搜搜真不错,方便
懒得堕落  2009年06月12日
好用
Frank  2009年06月11日
学习学习
glm9008  2009年06月08日
高手很多 多学习
CAD0516  2009年06月06日
好像从2008开始就只支持这种方式
garin25078  2009年06月02日
真的不错啊
chengui  2009年06月01日
学习中!
字数在300字内
请如实评论
CopyRight (C) codesoso.com 2007-2009 All Rights Reserved   免责声明