[英]How can I read a file in the UI thread
我有这样的代码,但是当我运行它时显示“:
不应在UI线程上执行同步操作。 考虑将此方法包装在Task.Run中
我该如何解决? 谢谢
public guchi()
{
string[] list = File.ReadAllLines(@"C:\Users\sample.csv");
foreach (string item in list)
{
var tmp = item.Split(';');
this.Add(new guchi()
{
test = tmp[0],
fun = tmp[1],
happy = tmp[2],
run = tmp[3],
now = tmp[4],
god = tmp[5],
time = tmp[6],
final= tmp[7],
Pyke = tmp[8],
Xinzhao = tmp[9]
});
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.