我snaged本次从网上递归搜索所有包括subdirectoires问题搜索子目录
的文件如果我指出这一点子大面积(即我的文档或C :)我得到一个错误:
The CLR has been unable to transition from COM context 0x1f6c48 to COM context 0x1f6db8 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
下面是代码 (我相信它,因为个子自称)
void DirSearch(string sDir)
{
try
{
foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d))
{
string hash = GetMD5HashFromFile(f);
Dic_Files.Add(f, hash);
}
DirSearch(d);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
}
看起来像一个相当无害的目录扫描例程。如果可行的话,您可以发布异常的调用堆栈以及GetMD5HashFromFile()的实现吗? – 2009-08-13 17:47:57