我想弄清楚保持我的應用程序響應的最佳方式。下面顯示了我目前正在使用的代碼。我發現的是後臺工作者線程是要走的路。後臺工作線程
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