Note that there are some explanatory texts on larger screens.

plurals
  1. POKill one button event when new button clicked
    text
    copied!<p>How to kill one button's event when a new button is clicked.</p> <p>I have one event (Button G) running.(has a while loop waiting for some input). I have a another button for quit operation. Now. I cannot click any other button when button G's event is running. How can I solve that? Thanks</p> <p>Hi, @Grokodile thank you for your code. So I commented your code here, Should I put my job logic code where I commented below? Thans</p> <pre><code> using System; using System.ComponentModel; using System.Threading; using System.Windows; using System.Windows.Threading; namespace WpfApplication1 { /// &lt;summary&gt; /// Interaction logic for MainWindow.xaml /// &lt;/summary&gt; public partial class MainWindow : Window { private BackgroundWorker _worker; public MainWindow() { InitializeComponent(); } private void RunButtonClickHandler(object sender, RoutedEventArgs e) { _worker = new BackgroundWorker {WorkerSupportsCancellation = true}; _worker.DoWork += BackgroundWorkerTask; _worker.RunWorkerAsync();        //I should Put my job logic here, right? } private void StopButtonClickHandler(object sender, RoutedEventArgs e) { if (_worker != null &amp;&amp; _worker.IsBusy) _worker.CancelAsync(); //I should Put my job logic here, right? } private void BackgroundWorkerTask(object sender, DoWorkEventArgs e) { // this runs on the BackgroundWorker thread. while (_worker.CancellationPending == false) { Thread.Sleep(500); // You have to use the Dispatcher to transfer the effects of // work done in the worker thread back onto the UI thread. Dispatcher.BeginInvoke(new Action(UpdateTime), DispatcherPriority.Normal, null); } } private void UpdateTime() { // Dispatcher runs this on the UI thread. timeTextBlock.Text = DateTime.Now.ToString(); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload