c# Stopky (STOP nebo PAUSE)
Zdravím,
udělal jsem si v c# winform stopky, zapnout mi jdou, ale nevím, jak udělat aby se zastavili (pause) a když dám zase start, tak aby jeli dál něco jako resume.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
namespace Pocitadlo
{
public partial class Form1 : Form
{
public int test = 0, mins, secs;
Thread stopky;
public Form1()
{
InitializeComponent();
}
public void START_Click(object sender, EventArgs e)
{
if (START.Text == "START")
{
START.Text = "STOP";
cas.Enabled = true;
stopky = new Thread(starter);
stopky.Start();
}
else
{
START.Text = "START";
cas.Enabled = false;
}
}
public void starter()
{
for (secs = 0; secs <= 59; secs++)
{
Thread.Sleep(200);
if (mins < 9 && secs < 9)
{
cas.BeginInvoke(new Action (() => cas.Text = String.Format("0{0}:0{1}", mins, secs)));
}
else if (mins < 9)
{
if (secs == 59)
{
mins++;
cas.BeginInvoke(new Action(() => cas.Text = String.Format("0{0}:00", mins)));
secs = 0 - 1;
}
else
{
cas.BeginInvoke(new Action(() => cas.Text = String.Format("0{0}:{1}", mins, secs)));
}
}
}
}
}
}