Workerthread in .Net 1.1
-
Hello, I'm looking for a simple sample (or a utility class) on how to build a workerthread for a windows forms application in .Net 1.1. But a search on the articles didn't help really. Following I'd like to do: -> Start the App and display a Form -> Upon "start" button click start the thread (it is doing a couple of database and file operations, each of which must be completed entirely, before processing the next one) -> The thread should be able to update a progress bar on the form and a couple of labels -> When the user hits the "pause" button, the thread must complete the single operation it is currently working on and then wait until the user stops the whole thing completely or hits the "continue" button Can anyone please point me into the right direction? Thanks in advance!
/matthias
I love deadlines. I like the whooshing sound they make as they fly by.
[Douglas Adams] -
Hello, I'm looking for a simple sample (or a utility class) on how to build a workerthread for a windows forms application in .Net 1.1. But a search on the articles didn't help really. Following I'd like to do: -> Start the App and display a Form -> Upon "start" button click start the thread (it is doing a couple of database and file operations, each of which must be completed entirely, before processing the next one) -> The thread should be able to update a progress bar on the form and a couple of labels -> When the user hits the "pause" button, the thread must complete the single operation it is currently working on and then wait until the user stops the whole thing completely or hits the "continue" button Can anyone please point me into the right direction? Thanks in advance!
/matthias
I love deadlines. I like the whooshing sound they make as they fly by.
[Douglas Adams]Here is an application that I made for an interview that calculates prime numbers.
//Purpose:to find prime numbers
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
using System.Threading;
using System.IO;namespace Primes
{public class MainForm : System.Windows.Forms.Form { private System.Windows.Forms.Button cmdDoit; private System.Windows.Forms.ListBox lbPrimes; private System.Windows.Forms.ProgressBar pbPrimes; private System.Windows.Forms.Label lblValue; Thread t; public MainForm() { InitializeComponent(); } \[STAThread\] public static void Main(string\[\] args) { Application.Run(new MainForm()); } #region Windows Forms Designer generated code /// /// This method is required for Windows Forms designer support. /// Do not change the method contents inside the source code editor. The Forms designer might /// not be able to load this method if it was changed manually. /// private void InitializeComponent() { this.lblValue = new System.Windows.Forms.Label(); this.pbPrimes = new System.Windows.Forms.ProgressBar(); this.lbPrimes = new System.Windows.Forms.ListBox(); this.cmdDoit = new System.Windows.Forms.Button(); this.SuspendLayout(); // // lblValue // this.lblValue.Location = new System.Drawing.Point(8, 64); this.lblValue.Name = "lblValue"; this.lblValue.TabIndex = 3; // // pbPrimes // this.pbPrimes.Location = new System.Drawing.Point(8, 40); this.pbPrimes.Name = "pbPrimes"; this.pbPrimes.TabIndex = 2; // // lbPrimes // this.lbPrimes.Location = new System.Drawing.Point(8, 96); this.lbPrimes.Name = "lbPrimes"; this.lbPrimes.Size = new System.Drawing.Size(136, 290); this.lbPrimes.TabIndex = 0; // // cmdDoit // this.cmdDoit.Location = new System.Drawing.Point(8, 8); this.cmdDoit.Name = "cmdDoit"; this.cmdDoit.TabIndex = 1; this.cmdDoit.Text = "Calculate"; this.cmdDoit.Click += new System.EventHandler(this.CmdDoitClick); // // MainForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(152, 398); this.Controls.Add(this.lblValue); this.Controls.Add(this.pbPrimes); this.Controls.Add(this.cmdDoit); this.Controls.Add(this.lbPrimes); this.Name = "MainForm"; this.Text = "Primes"; this.Closing += new System.Componen