<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FGUI_Windows_Form%2FThread_and_UI</id>
		<title>Csharp/C Sharp/GUI Windows Form/Thread and UI - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FGUI_Windows_Form%2FThread_and_UI"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/GUI_Windows_Form/Thread_and_UI&amp;action=history"/>
		<updated>2026-04-29T20:33:38Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/GUI_Windows_Form/Thread_and_UI&amp;diff=152&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/GUI_Windows_Form/Thread_and_UI&amp;diff=152&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/GUI_Windows_Form/Thread_and_UI&amp;diff=153&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/GUI_Windows_Form/Thread_and_UI&amp;diff=153&amp;oldid=prev"/>
				<updated>2010-05-26T11:33:37Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Background processing in a thread.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class Form1 : System.Windows.Forms.Form {&lt;br /&gt;
    private System.Windows.Forms.Label label1;&lt;br /&gt;
    private System.Windows.Forms.Button button1;&lt;br /&gt;
    private System.Windows.Forms.Label ValueLabel;&lt;br /&gt;
    private System.Windows.Forms.Button button2;&lt;br /&gt;
    private System.ruponentModel.Container components = null;&lt;br /&gt;
    private Thread fThread;&lt;br /&gt;
    private int fValue;&lt;br /&gt;
    public Form1() {&lt;br /&gt;
        fValue = 0;&lt;br /&gt;
        this.label1 = new System.Windows.Forms.Label();&lt;br /&gt;
        this.button1 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.ValueLabel = new System.Windows.Forms.Label();&lt;br /&gt;
        this.button2 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.SuspendLayout();&lt;br /&gt;
        this.label1.Location = new System.Drawing.Point(24, 32);&lt;br /&gt;
        this.label1.Size = new System.Drawing.Size(80, 16);&lt;br /&gt;
        this.label1.Text = &amp;quot;Value of Data:&amp;quot;;&lt;br /&gt;
        this.button1.Location = new System.Drawing.Point(232, 32);&lt;br /&gt;
        this.button1.Text = &amp;quot;&amp;amp;Update&amp;quot;;&lt;br /&gt;
        this.button1.Click += new&lt;br /&gt;
             System.EventHandler(this.button1_Click);&lt;br /&gt;
        this.ValueLabel.Location = new System.Drawing.Point(120, 32);&lt;br /&gt;
        this.button2.Location = new System.Drawing.Point(104, 88);&lt;br /&gt;
        this.button2.Name = &amp;quot;button2&amp;quot;;&lt;br /&gt;
        this.button2.RightToLeft =&lt;br /&gt;
             System.Windows.Forms.RightToLeft.No;&lt;br /&gt;
        this.button2.Size = new System.Drawing.Size(96, 23);&lt;br /&gt;
        this.button2.Text = &amp;quot;Start Thread&amp;quot;;&lt;br /&gt;
        this.button2.Click += new&lt;br /&gt;
             System.EventHandler(this.button2_Click);&lt;br /&gt;
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
        this.ClientSize = new System.Drawing.Size(336, 141);&lt;br /&gt;
        this.Controls.AddRange(new System.Windows.Forms.Control[] {&lt;br /&gt;
          this.button2,&lt;br /&gt;
          this.ValueLabel,&lt;br /&gt;
          this.button1,&lt;br /&gt;
          this.label1});&lt;br /&gt;
        this.ResumeLayout(false);&lt;br /&gt;
    }&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Application.Run(new Form1());&lt;br /&gt;
    }&lt;br /&gt;
    private void ThreadProc() {&lt;br /&gt;
        while (fValue &amp;lt; 1000) {&lt;br /&gt;
            Thread.Sleep(1000);&lt;br /&gt;
            fValue++;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void button2_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        fThread = new Thread(new ThreadStart(ThreadProc));&lt;br /&gt;
        fThread.IsBackground = true;&lt;br /&gt;
        fThread.Start();&lt;br /&gt;
    }&lt;br /&gt;
    private void button1_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        this.ValueLabel.Text = fValue.ToString();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Starting and stopping a thread.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class Form1 : System.Windows.Forms.Form {&lt;br /&gt;
    private System.Windows.Forms.Button button1;&lt;br /&gt;
    private System.Windows.Forms.Button button2;&lt;br /&gt;
    private System.Windows.Forms.Label label1;&lt;br /&gt;
    private System.Windows.Forms.Label label2;&lt;br /&gt;
    private System.Windows.Forms.Label NumThreads;&lt;br /&gt;
    private System.Windows.Forms.Label Counter;&lt;br /&gt;
    private int fCounter;&lt;br /&gt;
    private ArrayList fThreadList;&lt;br /&gt;
    private System.ruponentModel.Container components = null;&lt;br /&gt;
    public Form1() {&lt;br /&gt;
        InitializeComponent();&lt;br /&gt;
        fThreadList = new ArrayList();&lt;br /&gt;
    }&lt;br /&gt;
    protected override void Dispose(bool disposing) {&lt;br /&gt;
        if (disposing) {&lt;br /&gt;
            if (components != null) {&lt;br /&gt;
                components.Dispose();&lt;br /&gt;
                for (int i = 0; i &amp;lt; fThreadList.Count; ++i) {&lt;br /&gt;
                    Thread fThread = (Thread)fThreadList[i];&lt;br /&gt;
                    fThread.Abort();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        base.Dispose(disposing);&lt;br /&gt;
    }&lt;br /&gt;
    private void InitializeComponent() {&lt;br /&gt;
        this.button1 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.button2 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.label1 = new System.Windows.Forms.Label();&lt;br /&gt;
        this.label2 = new System.Windows.Forms.Label();&lt;br /&gt;
        this.NumThreads = new System.Windows.Forms.Label();&lt;br /&gt;
        this.Counter = new System.Windows.Forms.Label();&lt;br /&gt;
        this.SuspendLayout();&lt;br /&gt;
        this.button1.Location = new System.Drawing.Point(32, 104);&lt;br /&gt;
        this.button1.Name = &amp;quot;button1&amp;quot;;&lt;br /&gt;
        this.button1.TabIndex = 0;&lt;br /&gt;
        this.button1.Text = &amp;quot;&amp;amp;Start&amp;quot;;&lt;br /&gt;
        this.button1.Click += new&lt;br /&gt;
             System.EventHandler(this.button1_Click);&lt;br /&gt;
        this.button2.Location = new System.Drawing.Point(136, 104);&lt;br /&gt;
        this.button2.Name = &amp;quot;button2&amp;quot;;&lt;br /&gt;
        this.button2.Size = new System.Drawing.Size(88, 24);&lt;br /&gt;
        this.button2.TabIndex = 1;&lt;br /&gt;
        this.button2.Text = &amp;quot;&amp;amp;Stop&amp;quot;;&lt;br /&gt;
        this.button2.Click += new&lt;br /&gt;
             System.EventHandler(this.button2_Click);&lt;br /&gt;
        this.label1.Location = new System.Drawing.Point(32, 40);&lt;br /&gt;
        this.label1.Name = &amp;quot;label1&amp;quot;;&lt;br /&gt;
        this.label1.Size = new System.Drawing.Size(152, 16);&lt;br /&gt;
        this.label1.TabIndex = 2;&lt;br /&gt;
        this.label1.Text = &amp;quot;Number of Threads Running:&amp;quot;;&lt;br /&gt;
        this.label2.Location = new System.Drawing.Point(32, 64);&lt;br /&gt;
        this.label2.Name = &amp;quot;label2&amp;quot;;&lt;br /&gt;
        this.label2.Size = new System.Drawing.Size(100, 16);&lt;br /&gt;
        this.label2.TabIndex = 3;&lt;br /&gt;
        this.label2.Text = &amp;quot;Counter:&amp;quot;;&lt;br /&gt;
        this.NumThreads.Location = new System.Drawing.Point(192, 40);&lt;br /&gt;
        this.NumThreads.Name = &amp;quot;NumThreads&amp;quot;;&lt;br /&gt;
        this.NumThreads.Size = new System.Drawing.Size(64, 16);&lt;br /&gt;
        this.NumThreads.TabIndex = 4;&lt;br /&gt;
        this.Counter.Location = new System.Drawing.Point(192, 64);&lt;br /&gt;
        this.Counter.Name = &amp;quot;Counter&amp;quot;;&lt;br /&gt;
        this.Counter.Size = new System.Drawing.Size(64, 16);&lt;br /&gt;
        this.Counter.TabIndex = 5;&lt;br /&gt;
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
        this.ClientSize = new System.Drawing.Size(272, 165);&lt;br /&gt;
        this.Controls.AddRange(new System.Windows.Forms.Control[] {&lt;br /&gt;
        this.Counter,&lt;br /&gt;
        this.NumThreads,&lt;br /&gt;
        this.label2,&lt;br /&gt;
        this.label1,&lt;br /&gt;
        this.button2,&lt;br /&gt;
        this.button1});&lt;br /&gt;
        this.ResumeLayout(false);&lt;br /&gt;
    }&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Application.Run(new Form1());&lt;br /&gt;
    }&lt;br /&gt;
    protected void ThreadFunc() {&lt;br /&gt;
        Boolean done = false;&lt;br /&gt;
        while (!done) {&lt;br /&gt;
            Thread.Sleep(1000);&lt;br /&gt;
            fCounter++;&lt;br /&gt;
            this.Counter.Text = fCounter.ToString();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void button1_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        Thread fThread = new Thread(new ThreadStart(ThreadFunc));&lt;br /&gt;
        fThread.Start();&lt;br /&gt;
        fThreadList.Add(fThread);&lt;br /&gt;
        this.NumThreads.Text = fThreadList.Count.ToString();&lt;br /&gt;
    }&lt;br /&gt;
    private void button2_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        Thread fThread = (Thread)fThreadList[fThreadList.Count - 1];&lt;br /&gt;
        fThread.Abort();&lt;br /&gt;
        fThreadList.Remove(fThread);&lt;br /&gt;
        this.NumThreads.Text = fThreadList.Count.ToString();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Talking to a visual element in a background thread.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class Form1 : System.Windows.Forms.Form {&lt;br /&gt;
    private System.Windows.Forms.ProgressBar progressBar1;&lt;br /&gt;
    private System.Windows.Forms.Button button1;&lt;br /&gt;
    private System.Windows.Forms.Button button2;&lt;br /&gt;
    private Thread fThread = null;&lt;br /&gt;
    private System.ruponentModel.Container components = null;&lt;br /&gt;
    public Form1() {&lt;br /&gt;
        this.progressBar1 = new System.Windows.Forms.ProgressBar();&lt;br /&gt;
        this.button1 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.button2 = new System.Windows.Forms.Button();&lt;br /&gt;
        this.SuspendLayout();&lt;br /&gt;
        this.progressBar1.Location = new System.Drawing.Point(24, 32);&lt;br /&gt;
        this.progressBar1.Name = &amp;quot;progressBar1&amp;quot;;&lt;br /&gt;
        this.progressBar1.Size = new System.Drawing.Size(264, 23);&lt;br /&gt;
        this.progressBar1.TabIndex = 0;&lt;br /&gt;
        this.button1.Location = new System.Drawing.Point(24, 80);&lt;br /&gt;
        this.button1.Size = new System.Drawing.Size(136, 40);&lt;br /&gt;
        this.button1.Text = &amp;quot;Start Thread&amp;quot;;&lt;br /&gt;
        this.button1.Click += new&lt;br /&gt;
             System.EventHandler(this.button1_Click);&lt;br /&gt;
        this.button2.Location = new System.Drawing.Point(168, 80);&lt;br /&gt;
        this.button2.Size = new System.Drawing.Size(120, 40);&lt;br /&gt;
        this.button2.Text = &amp;quot;Stop Thread&amp;quot;;&lt;br /&gt;
        this.button2.Click += new&lt;br /&gt;
             System.EventHandler(this.button2_Click);&lt;br /&gt;
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
        this.ClientSize = new System.Drawing.Size(704, 429);&lt;br /&gt;
        this.Controls.AddRange(new System.Windows.Forms.Control[] {&lt;br /&gt;
          this.button2,&lt;br /&gt;
          this.button1,&lt;br /&gt;
          this.progressBar1});&lt;br /&gt;
        this.ResumeLayout(false);&lt;br /&gt;
    }&lt;br /&gt;
    protected override void Dispose(bool disposing) {&lt;br /&gt;
        if (fThread != null) {&lt;br /&gt;
            fThread.Interrupt();&lt;br /&gt;
            fThread = null;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Application.Run(new Form1());&lt;br /&gt;
    }&lt;br /&gt;
    private void UpdateProgress() {&lt;br /&gt;
        if (progressBar1.Value == progressBar1.Maximum) {&lt;br /&gt;
            progressBar1.Value = progressBar1.Minimum;&lt;br /&gt;
        }&lt;br /&gt;
        progressBar1.PerformStep();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public void ThreadProc() {&lt;br /&gt;
        try {&lt;br /&gt;
            MethodInvoker mi = new MethodInvoker(this.UpdateProgress);&lt;br /&gt;
            while (true) {&lt;br /&gt;
                this.BeginInvoke(mi);&lt;br /&gt;
                Thread.Sleep(500);&lt;br /&gt;
            }&lt;br /&gt;
        } catch (ThreadInterruptedException e) {&lt;br /&gt;
            Console.WriteLine(&lt;br /&gt;
              &amp;quot;Interruption Exception in Thread: {0}&amp;quot;,&lt;br /&gt;
                  e);&lt;br /&gt;
        } catch (Exception we) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Exception in Thread: {0}&amp;quot;, we);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void button1_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        fThread = new Thread(new ThreadStart(ThreadProc));&lt;br /&gt;
        fThread.IsBackground = true;&lt;br /&gt;
        fThread.Start();&lt;br /&gt;
    }&lt;br /&gt;
    private void button2_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        fThread.Interrupt();&lt;br /&gt;
        fThread = null;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Thread and UI Demo==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Data;&lt;br /&gt;
public struct MyData {&lt;br /&gt;
    public double pi;&lt;br /&gt;
    public int iters;&lt;br /&gt;
}&lt;br /&gt;
public class Calc {&lt;br /&gt;
    private double _pi;&lt;br /&gt;
    private int _iters;&lt;br /&gt;
    private readonly int TotalIters;&lt;br /&gt;
    public Calc(int it) {&lt;br /&gt;
        _iters = 1;&lt;br /&gt;
        _pi = 0;&lt;br /&gt;
        TotalIters = it;&lt;br /&gt;
    }&lt;br /&gt;
    public MyData PI {&lt;br /&gt;
        get {&lt;br /&gt;
            MyData pi = new MyData();&lt;br /&gt;
            lock (this) {&lt;br /&gt;
                pi.pi = _pi;&lt;br /&gt;
                pi.iters = _iters;&lt;br /&gt;
            }&lt;br /&gt;
            return pi;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public Thread MakeThread() {&lt;br /&gt;
        return new Thread(new ThreadStart(this.ThreadStarter));&lt;br /&gt;
    }&lt;br /&gt;
    private void calculate() {&lt;br /&gt;
        double series = 0;&lt;br /&gt;
        do {&lt;br /&gt;
            series ++;&lt;br /&gt;
            lock (this) {&lt;br /&gt;
                _iters += 4;&lt;br /&gt;
                _pi = series * 4;&lt;br /&gt;
            }&lt;br /&gt;
        } while (_iters &amp;lt; TotalIters);&lt;br /&gt;
    }&lt;br /&gt;
    private void ThreadStarter() {&lt;br /&gt;
        try {&lt;br /&gt;
            calculate();&lt;br /&gt;
        } catch (ThreadAbortException e) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;ThreadAbortException&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class Form1 : System.Windows.Forms.Form {&lt;br /&gt;
    private System.Windows.Forms.Label label1;&lt;br /&gt;
    private System.Windows.Forms.TextBox PiValue;&lt;br /&gt;
    private System.Windows.Forms.Label label2;&lt;br /&gt;
    private System.Windows.Forms.TextBox Iteratons;&lt;br /&gt;
    private Calc pi = new Calc(100000000);&lt;br /&gt;
    private Thread calcThread = null;&lt;br /&gt;
    private System.Windows.Forms.Timer timer1;&lt;br /&gt;
    private System.Windows.Forms.Button StopButton;&lt;br /&gt;
    private System.Windows.Forms.Button Pause;&lt;br /&gt;
    private System.ruponentModel.IContainer components;&lt;br /&gt;
    public Form1() {&lt;br /&gt;
        this.label1 = new System.Windows.Forms.Label();&lt;br /&gt;
        this.label2 = new System.Windows.Forms.Label();&lt;br /&gt;
        this.Pause = new System.Windows.Forms.Button();&lt;br /&gt;
        this.PiValue = new System.Windows.Forms.TextBox();&lt;br /&gt;
        this.StopButton = new System.Windows.Forms.Button();&lt;br /&gt;
        this.timer1 = new System.Windows.Forms.Timer(this.ruponents);&lt;br /&gt;
        this.Iteratons = new System.Windows.Forms.TextBox();&lt;br /&gt;
        this.SuspendLayout();&lt;br /&gt;
        // &lt;br /&gt;
        // label1&lt;br /&gt;
        // &lt;br /&gt;
        this.label1.Location = new System.Drawing.Point(8, 24);&lt;br /&gt;
        this.label1.Name = &amp;quot;label1&amp;quot;;&lt;br /&gt;
        this.label1.TabIndex = 0;&lt;br /&gt;
        this.label1.Text = &amp;quot;Value  of PI:&amp;quot;;&lt;br /&gt;
        // &lt;br /&gt;
        // label2&lt;br /&gt;
        // &lt;br /&gt;
        this.label2.Location = new System.Drawing.Point(8, 72);&lt;br /&gt;
        this.label2.Name = &amp;quot;label2&amp;quot;;&lt;br /&gt;
        this.label2.TabIndex = 2;&lt;br /&gt;
        this.label2.Text = &amp;quot;Iterations:&amp;quot;;&lt;br /&gt;
        // &lt;br /&gt;
        // Pause&lt;br /&gt;
        // &lt;br /&gt;
        this.Pause.Location = new System.Drawing.Point(24, 112);&lt;br /&gt;
        this.Pause.Name = &amp;quot;Pause&amp;quot;;&lt;br /&gt;
        this.Pause.TabIndex = 5;&lt;br /&gt;
        this.Pause.Text = &amp;quot;Pause&amp;quot;;&lt;br /&gt;
        this.Pause.Click += new System.EventHandler(this.Pause_Click);&lt;br /&gt;
        // &lt;br /&gt;
        // PiValue&lt;br /&gt;
        // &lt;br /&gt;
        this.PiValue.Location = new System.Drawing.Point(128, 24);&lt;br /&gt;
        this.PiValue.Name = &amp;quot;PiValue&amp;quot;;&lt;br /&gt;
        this.PiValue.ReadOnly = true;&lt;br /&gt;
        this.PiValue.Size = new System.Drawing.Size(136, 20);&lt;br /&gt;
        this.PiValue.TabIndex = 1;&lt;br /&gt;
        this.PiValue.Text = &amp;quot;&amp;quot;;&lt;br /&gt;
        // &lt;br /&gt;
        // StopButton&lt;br /&gt;
        // &lt;br /&gt;
        this.StopButton.Location = new System.Drawing.Point(200, 112);&lt;br /&gt;
        this.StopButton.Name = &amp;quot;StopButton&amp;quot;;&lt;br /&gt;
        this.StopButton.TabIndex = 4;&lt;br /&gt;
        this.StopButton.Text = &amp;quot;Stop&amp;quot;;&lt;br /&gt;
        this.StopButton.Click += new System.EventHandler(this.StopButton_Click);&lt;br /&gt;
        // &lt;br /&gt;
        this.timer1.Enabled = true;&lt;br /&gt;
        this.timer1.Tick += new System.EventHandler(this.timer1_Tick);&lt;br /&gt;
        // &lt;br /&gt;
        this.Iteratons.Location = new System.Drawing.Point(128, 72);&lt;br /&gt;
        this.Iteratons.Name = &amp;quot;Iteratons&amp;quot;;&lt;br /&gt;
        this.Iteratons.ReadOnly = true;&lt;br /&gt;
        this.Iteratons.TabIndex = 3;&lt;br /&gt;
        this.Iteratons.Text = &amp;quot;&amp;quot;;&lt;br /&gt;
        // &lt;br /&gt;
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
        this.ClientSize = new System.Drawing.Size(292, 149);&lt;br /&gt;
        this.Controls.AddRange(new System.Windows.Forms.Control[]  {&lt;br /&gt;
                                                                  this.Pause,&lt;br /&gt;
                                                                  this.StopButton,&lt;br /&gt;
                                                                  this.Iteratons,&lt;br /&gt;
                                                                  this.label2,&lt;br /&gt;
                                                                  this.PiValue,&lt;br /&gt;
                                                                  this.label1});&lt;br /&gt;
        this.Load += new System.EventHandler(this.Form1_Load);&lt;br /&gt;
        this.Closed += new System.EventHandler(this.Form1_Closed);&lt;br /&gt;
        this.ResumeLayout(false);&lt;br /&gt;
    }&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Application.Run(new Form1());&lt;br /&gt;
    }&lt;br /&gt;
    private void Form1_Load(object sender, System.EventArgs e) {&lt;br /&gt;
        calcThread = pi.MakeThread();&lt;br /&gt;
        calcThread.Priority = ThreadPriority.Lowest;&lt;br /&gt;
        calcThread.Start();&lt;br /&gt;
    }&lt;br /&gt;
    private void timer1_Tick(object sender, System.EventArgs e) {&lt;br /&gt;
        if (this.Pause.Text == &amp;quot;Pause&amp;quot;) {&lt;br /&gt;
            MyData p = pi.PI;&lt;br /&gt;
            this.PiValue.Text = p.pi.ToString();&lt;br /&gt;
            this.Iteratons.Text = p.iters.ToString();&lt;br /&gt;
        }&lt;br /&gt;
        if (calcThread.IsAlive == false) {&lt;br /&gt;
            StopButton.Enabled = false;&lt;br /&gt;
            Pause.Enabled = false;&lt;br /&gt;
            timer1.Enabled = false;&lt;br /&gt;
            calcThread = null;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void StopButton_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        StopButton.Enabled = false;&lt;br /&gt;
        Pause.Enabled = false;&lt;br /&gt;
        timer1.Enabled = false;&lt;br /&gt;
        calcThread.Abort();&lt;br /&gt;
        calcThread.Join();&lt;br /&gt;
        calcThread = null;&lt;br /&gt;
    }&lt;br /&gt;
    private void Pause_Click(object sender, System.EventArgs e) {&lt;br /&gt;
        if (this.Pause.Text == &amp;quot;Pause&amp;quot;) {&lt;br /&gt;
            calcThread.Suspend();&lt;br /&gt;
            this.Pause.Text = &amp;quot;Resume&amp;quot;;&lt;br /&gt;
            this.StopButton.Enabled = false;&lt;br /&gt;
        } else {&lt;br /&gt;
            calcThread.Resume();&lt;br /&gt;
            this.Pause.Text = &amp;quot;Pause&amp;quot;;&lt;br /&gt;
            this.StopButton.Enabled = true;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private void Form1_Closed(object sender, System.EventArgs e) {&lt;br /&gt;
        if (calcThread != null) {&lt;br /&gt;
            calcThread.Abort();&lt;br /&gt;
            calcThread.Join();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>