All pastes #510816 Raw Edit

Something

public text v1 · immutable
#510816 ·published 2007-05-26 02:26 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        Thread blah;
        public Form1()
        {
            InitializeComponent();
            blah = new Thread(new ThreadStart(updateCounter));
            blah.IsBackground = true;
        }
        int counterVariable = 0;
        public void startButton1_Click(object sender, EventArgs e)
        {
            blah.Start();
        }
        public void updateCounter()
        {
            do
            {
                counterVariable++;
                this.Invoke(delegate()
                {
                    counterLabel1.Text = counterVariable.ToString();
                });
            }
            while (counterVariable < 500);
        }

        public void stopButton1_Click(object sender, EventArgs e)
        {
            blah.Suspend();
        }
        
    }
}