如何在C#中指定的时间后取消后台工作者 [英] how to cancel background worker after specified time in c#

查看:87
本文介绍了如何在C#中指定的时间后取消后台工作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#中指定的时间后取消后台工作人员或取消不响应的后台工作人员.

how to cancel background worker after specified time in c# or cancel not responding background worker.

推荐答案

查看本教程: http://www.albahari.com/threading/part3.aspx

为了使System.ComponentModel.BackgroundWorker线程支持取消,您需要在启动线程之前将WorkerSupportsCancellation属性设置为True.

In order for a System.ComponentModel.BackgroundWorker thread to support cancellation, you need to set the WorkerSupportsCancellation property to True before starting the thread.

然后您可以调用BackgroundWorker的.CancelAsync方法来取消线程.

You can then call the .CancelAsync method of the BackgroundWorker to cancel the thread.

这篇关于如何在C#中指定的时间后取消后台工作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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