在线程.NET [英] Threading in .net

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

问题描述

我有一个WinForms应用程序,我选择一个目录选择一个目录,通过目录点击一个按钮,循环,目录中的每个文件复制到另一个目录的一个简单的例子。



我想要做在后台线程文件拷贝,以避免锁定GUI



我正在寻找最简单的解决方案:




  1. 创建后台线程

  2. 转至

  3. 源和目的地
  4. 获取进步的回调,所以我可以显示GUI线程上的进度条


解决方案

我会建议使用 BackgroundWorker的类。




I have a simple example of a winforms application where i choose a directory in a directory chooser and click a button to loop through the directory and copy each file in the directory into another directory.

i want to do the file copy on a background thread to avoid locking the GUI.

i am looking for the simplest solution to:

  1. Create the background thread
  2. Pass the source and destinations in
  3. Get a callback on progress so i can show a progress bar on the GUI thread

解决方案

I would recommend using the BackgroundWorker class.

Example.

这篇关于在线程.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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