| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1239 人关注过本帖
标题:刚学用C#边个界面,没想到有个警告,不懂,求助啊!!!
只看楼主 加入收藏
xinxishehan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-11-27
收藏
 问题点数:0 回复次数:0 
刚学用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
搜索更多相关主题的帖子: class private public 动态 
2011-11-27 15:02
快速回复:刚学用C#边个界面,没想到有个警告,不懂,求助啊!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017156 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved