【发布时间】:2011-04-14 13:33:07
【问题描述】:
我正在尝试找出让我的应用程序保持响应的最佳方法。下面显示了我目前正在使用的代码。我发现后台工作线程是要走的路。
private void cleanFiles()
{
if (listView1.CheckedItems.Count != 0)
{
// If so, loop through all checked files and delete.
foreach (ListViewItem item in listView1.CheckedItems)
{
string fileName = item.Text;
string filePath = Path.Combine(tFile + fileName);
try
{
File.Delete(filePath);
}
catch (Exception)
{
//ignore files being in use
}
MessageBox.Show("Files Cleaned");
}
}
else
{
MessageBox.Show("Please put a check by the files you want to delete");
}
}
}
}
【问题讨论】:
标签: c# winforms multithreading c#-4.0