我想弄清楚保持我的应用程序响应的最佳方式。下面显示了我目前正在使用的代码。我发现的是后台工作者线程是要走的路。后台工作线程
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");
}
}
}
}
后台工作人员帮助我。谢谢! – partialdata 2012-05-29 19:14:33