简体   繁体   English

停止按钮单击事件,其他按钮单击

[英]Stop button click event on other button click

how to access two button click method if first button doing work when we click second button? 如果单击第二个按钮时第一个按钮起作用,如何访问两个按钮的单击方法? I tried to access other button click event when first button click event is performing operation and I want to stop this execution and perform another operation 当第一个按钮单击事件正在执行操作时,我试图访问其他按钮单击事件,但我想停止执行该操作并执行其他操作

You are going to need to do some reading about asynchronous programming and then implement Cooperative Task Cancellation . 您将需要阅读一些有关异步编程的内容,然后实现协作任务取消

When you press the second button: 当您按下第二个按钮时:

  1. check that a task is in progress 检查任务是否在进行中
  2. if an operation is in progress, cancel the ongoing task and wait for it to 'complete' (cancel successfully) 如果正在进行一项操作,请取消正在进行的任务并等待其“完成” (成功取消)
  3. run your new operation 运行您的新操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM