Task.Run(() =>
{
Thread.Sleep(4000);
string sPower = getPower();//耗时操作一定要放在BeginInvoke的外面
this.BeginInvoke(new Action(() =>
{
lbCurrentPower.Text = sPower;
}));
});
string sPower = getPower();这一句是耗时操作,一定要放在BeginInvoke的外面,如果放在BeginInvoke或invoke的里面,则程序界面依然会被阻塞。