2个线程在Winforms中同时运行 [英] 2 threads running at a same time in winforms

查看:88
本文介绍了2个线程在Winforms中同时运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
实际上,我需要以Windows形式实现线程,其中一个线程应实现动画幻灯片放映,而另一个线程应执行其他工作.好像是在Visual Studio安装过程中发生的那样,用户将在其中看到幻灯片放映,并在后台进行所需的工作..pls请帮助我,这对我来说非常紧急..
谢谢
jaipal

hi everyone,
Actually i need to implement threads in Windows form,where one thread should implement animated slide show and another thread should do other work. As if it happens with visual studio installation,where user ll see the slide show and in background the required work will be carried..pls pls help me out its very urgent for me..
thank you
jaipal

推荐答案

在我对过去CodeProject问题的回答中,您会找到很多建议:

Control.Invoke()与Control.BeginInvoke() [ ^ ],
Treeview Scanner和MD5问题 [如何获取keydown事件在vb.net中的不同线程上操作 [启用禁用+多线程后控件事件不会触发 [ ^ ].

另请参阅我对线程包装器的建议:
如何将ref参数传递给线程 [ ^ ],
启动后更改线程(生产者)的参数 [ ^ ].

使用事件句柄进行线程同步:
ManualResetEvent和Thread中的AutoResetEvent [暂停正在运行的线程 [ Simple用于线程通信和线程间调用的阻塞队列 [ ^ ].

—SA
You will find a good deal of advice in my answers to past CodeProject questions:

Control.Invoke() vs. Control.BeginInvoke()[^],
Problem with Treeview Scanner And MD5[^],
How to get a keydown event to operate on a different thread in vb.net[^],
Control events not firing after enable disable + multithreading[^].

See also my advice of thread wrapper:
How to pass ref parameter to the thread[^],
change paramters of thread (producer) after it started[^].

Use of event handle for thread synchronization:
ManualResetEvent and AutoResetEvent in Thread[^],
pause running thread[^].

This Tips/Tricks article explains thread communication and synchronization via the blocking queue: Simple Blocking Queue for Thread Communication and Inter-thread Invocation[^].

—SA


多线程
长期以来,大多数编程应用程序都是单线程的.在当今世界,大多数应用程序都是单线程的,这意味着整个应用程序中只有一个线程.在完成进程B之前,您永远无法执行进程A.多线程应用程序允许您同时运行进程A和进程B,使用线程可以在四分之一的时间内完成程序.

C#中的多线程概念 [在c#中使用多线程 [
Multithread
For a long time, most programming applications were single-threaded. in now world most of the applications are single threaded, That means there was only one thread in the entire application. You could never do Process A until completing process B. A multithreaded application allows you to run process A and process B simulteniously, using threading you could finish your program in a quarter of the time.

Multithreading Concepts in C#[^]
Use of multithreading in c#[^]


这篇关于2个线程在Winforms中同时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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