本文介绍了如何在DoWork事件中停止Backgroundworker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将用于下载文件的代码放在backgroundWorker_DoWork()事件中.

I put the code for download file in the backgroundWorker_DoWork() event.

下载完成后,我想在backgroundWorker_DoWork事件中停止后台吗?

After complete download, I want to stop background in backgroundWorker_DoWork event?

以下两个之间哪个是正确的?

Which one is correct between following two?

1.  e.Cancel = true; //e是backgroundWorker_DoWork的第二个参数

1. e.Cancel = true; //e is 2'nd argument of backgroundWorker_DoWork

2.  backgroundWorker .CancelAsync();

2. backgroundWorker.CancelAsync();

推荐答案

为什么要停止后台工作?

Why you want to stop background worker?

工作完成后,默认情况下会退出...

Once it has finished its work, it exits by default...


这篇关于如何在DoWork事件中停止Backgroundworker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 08:32