winform的。 private void Reminder_Load(object sender, EventArgs e)//FormLoad事件
        {
            Control.CheckForIllegalCrossThreadCalls = false;//是否检查跨线程调用windows控件不安全?属性为 不检查
            th = new Thread(new ThreadStart(getDateTime));
            th.IsBackground = false;
            th.Start();
         }
        public void getDateTime()//获取当前时间
        {
            while (true)
            {
                lblDateTime.Text = DateTime.Now.ToString();                Thread.Sleep(50);
            }        }------------------------------有问题---------------------------
1、运行过后,内存一直在增加
2、谁给我讲下,abort(),join(),sleep()...等等?对于线程不太了解。请讲通俗点哦,网上的写得很繁琐。

解决方案 »

  1.   

     Abort()直接终止了        join是等待被锁定的对象被解锁后在进行,sleep让程序休眠了(暂时停止)
      

  2.   

    Reminder_Load调用了很多次吗?
    另外你为什么不用timer呢?
      

  3.   

    你把 th.IsBackground = false;
    拿掉看看 
      

  4.   

    线程分前台线程 和后台线程,只有所有的前台线程都结束后(不管后台线程结束没),系统就会完全结束进程
    Thread默认是前台线程,把th.IsBackground = false;就变成后台线程了
    按LZ的说法,莫非th线程一直没结束?
    那用Timer timer=new Timer(……)吧!它不会新建立线程的
      

  5.   


    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 WindowsFormsApplication9
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {        }        private void timer1_Tick(object sender, EventArgs e)
            {
                label1.Text = DateTime.Now.ToString();
            }    }
    }
    timer的interval属性为:250打开任务管理器,会看到内存在每2秒8KB增加。
    老师一直告诉我要慎用 timer控件各位大哥帮下忙?我只是简单的想label不断的显示系统当前时间而已,我容易吗我....
      

  6.   

    老师告诉你怎样算是慎用了吗?难道他是巫师,只管吓唬人?如果所谓“慎用”的结果就是造成你把在线程中写getDateTime那样的循环,那么老师真是害人精啊,怎么这个就不“慎用”了吗?!