Note that there are some explanatory texts on larger screens.

plurals
  1. POThreads suspend resume c#
    primarykey
    data
    text
    <p>Excuse my English; I have a problem with threads: I have a WinForm, in it I have two buttons (Play &amp; Pause) I wish that when you press the PLAY button, if it is created the thread, thought and start, and the PAUSE button to pause the thread. Then if the thread is paused, pressing the PLAY button resumes the thread from where it left off. Like a video game .... In Java I succeed doing something,</p> <pre><code>Runnable h = new MiHilo(); Thread t = new Thread(h); public void PLAYActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PLAYActionPerformed if (t.isAlive()) { t.resume(); } else { h = new MiHilo(); t = new Thread(h); t.start(); } } private void PAUSEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PAUSEActionPerformed if (!t.isAlive()) { JOptionPane.showMessageDialog(null, " ¿En qué está pensando?\nEs imposible pausar algo que no ha empezado.", "David", JOptionPane.ERROR_MESSAGE); } else { t.suspend(); } } class MiHilo implements Runnable { public void run() { // Code here... } } </code></pre> <p>How I can do this in C #? What if I would like, if not too much trouble to tell me an example of how to do something basic, Pausing and resuming, something simple, like a single WinForm with a label, and two buttons (Play &amp; Pause) when starting the label is written 0, if hit Play, it starts a thread that calls a function that has a for which varies from 1-1000 with a Sleep of 1 second to display as text on the label, and pause, when pressed would pause this count progressive, then the play would give, but without using Timers ...</p> <p>Hope it's not too much to ask, with that example I could adapt it to what I want.</p> <p>Thank you for your time!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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