刚学用C#边个界面,没想到有个警告,不懂,求助啊!!!
写的是一个动态显示进程执行进度的界面,最下面是警告,辛苦大侠看一下啊 using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace ch1_10
{
public partial class Form1 : Form
{
private int waitTime = 150;
private Thread barProgress;
public delegate void MethodInvoke();
public Form1()
{
InitializeComponent();
}
private void ProgressProc()
{
MethodInvoker mi = new MethodInvoker(UpdateProgress);
while (true)
{
Invoke(mi);
int sleeptime = this.waitTime;
Thread.Sleep(sleeptime);
}
}
private void UpdateProgress()
{
double completed;
double number;
if (progressBar1.Value == progressBar1.Maximum)
{
progressBar1.Value = progressBar1.Minimum;
}
else
{
progressBar1.PerformStep();
}
number = this.progressBar1.Value;
completed = (number / 100) * 100.0;
}
private void button1_Click(object sender, EventArgs e)
{
barProgress = new Thread(new ThreadStart(ProgressProc));
barProgress.IsBackground = true;
barProgress.Start();
button1.Enabled = false;
button2.Enabled = true;
button4.Enabled = true;
}
private void label4_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
progressBar1.Step = Int32.Parse((string)comboBox1.SelectedItem);
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
TrackBar tb = (TrackBar)sender;
int time = 160 - tb.Value;
this.waitTime = time;
}
private void button2_Click(object sender, EventArgs e)
{
barProgress.Suspend();
button3.Enabled = true;
button4.Enabled = false;
}
private void button3_Click(object sender, EventArgs e)
{
barProgress.Resume();
button3.Enabled = false;
button4.Enabled = true;
}
private void button4_Click(object sender, EventArgs e)
{
barProgress.Abort();
progressBar1.Value = 0;
progressBar1.Step = 1;
trackBar1.Value = 10;
comboBox1.SelectedIndex = 0;
this.waitTime = 150;
button1.Enabled = true;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
}
}
}
警告是警告 1 “System.Threading.Thread.Suspend()”已过时:“Thread.Suspend has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. http://go.” C:\Users\lele\Desktop\visual stdio 2008例程\ch1_10\ch1_10\Form1.cs 84 13 ch1_10
警告 2 “System.Threading.Thread.Resume()”已过时:“Thread.Resume has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. http://go.” C:\Users\lele\Desktop\visual stdio 2008例程\ch1_10\ch1_10\Form1.cs 91 13 ch1_10