关于线程问题, 我是新手 急急 !!!
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
lblTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string str = GetBanblance(Global_User.CurrentUser.UserName);
Global_User.CurrentUser.UserAccountRemain = Convert.ToInt32(str);
Refresh();
Thread.Sleep(1000);
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = (BackgroundWorker)sender;
}
private void MainForm1_Load(object sender, EventArgs e)
{
CheckForUpdate();
lblUserName.Text = Global_User.CurrentUser.UserName;
// GetBanblance(Global_User.CurrentUser.UserName);
//通道初始化数据显示
lbltongdaotype.Text = MainForm.Properties.Settings.Default.tongdao + " 通道限制字" + MainForm.Properties.Settings.Default.phoneNum;
backgroundWorker1.RunWorkerAsync();
}
代码都贴出来了,希望大虾们帮忙。。。。 里面的时间和账户余额怎么更新不了呢。。。 哪里出了问题
------解决方案--------------------
在backgroundWorker1_DoWork中去获取数据
比如while(!worker.CancellationPending)
{
//get data and compare with current data
//if data changed
worker.ReportProgress
Thread.Sleep(0);
}
另一边在worker的OnProgressChanged事件中加上你更新FORM的过程