停止并启动按钮C# [英] Stop and start button C#
本文介绍了停止并启动按钮C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
并且有一个停止按钮但是如果我的程序工作我不能访问表格按停止按钮
无论如何都可以在工作时访问表格吗?
我尝试了什么:
如何在程序运行时停止线程?
解决方案
看看BackgroundWorker类
MSDN BackgroundWorker类(System.ComponentModel) [ ^ ]
该链接将为您提供课程参考和示例
亲切的问候
而不是使用后台工作线程,虽然它确实可以很好地工作,但你应该考虑使用'任务'
.net中的任务可以等待和取消很容易
任务取消| Microsoft Docs [ ^ ]
hey, i made a start button and its to start the action or the job i want from my program to do
and there is a stop button to but if my program working i can't access to form to press stop button
is there anyway to make access to form while working possible ?
What I have tried:
how to stop threading while program working ?
解决方案
Take a look at the BackgroundWorker class
MSDN BackgroundWorker Class (System.ComponentModel)[^]
The link will provide you with the class reference and examples
Kind Regards
Instead of using a Background Worker thread, which is sort-of old-school, though it does work quite well admittedly, You should consider using a 'Task'
Tasks in .net can be awaited and cancelled pretty easily
Task Cancellation | Microsoft Docs[^]
这篇关于停止并启动按钮C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文