110,538
社区成员
发帖
与我相关
我的任务
分享
private long GetFileLine(string path) {
long line = 0;
using (StreamReader reader = new StreamReader(path)) {
while (reader.ReadLine() != null) {
line++;
label1.BeginInvoke( //换成Invoke就没有问题
new MethodInvoker(() => label1.Text = path + " -> " + line
));
}
}
return line;
}
//调用的地方、、、
new Thread(() => {
long line = GetFileLine("C:\\fuck.txt");
textBox3.Invoke(new MethodInvoker(() => { //断点到这句F5就回到界面上了
textBox3.Text = "what a fucking day"; //这句下断点 没反映不到这里来
}));
//后面的代码也不执行了
}) { IsBackground = true }.Start();