有没有在dotNet的DirectoryInfo.GetFiles / Directory.GetDirectories异步版本?版本、DirectoryInfo、dotNet、GetFiles

2023-09-03 10:45:27 作者:少女心狙击手

有没有在dotNet的DirectoryInfo.GetFiles / Directory.GetDirectories异步版本?我想用它们在F#异步块,并且它会是不错的一个,可以调用AsyncCallbacks版本。

Is there an asynchronous version of DirectoryInfo.GetFiles / Directory.GetDirectories in dotNet? I'd like to use them in an F# async block, and it'd be nice to have a version that can be called with AsyncCallbacks.

但问题是我想在一堆目录吸,很可能在SMB坐骑通过慢速网络连接,而我不希望一堆线程池中的线程坐等网络读取时,他们可以做其他的工作。

Problem is I'm trying to suck in a bunch of directories, probably on SMB mounts over slow network connections, and I don't want a bunch of thread pool threads sitting around waiting for network reads when they could be doing other work.

推荐答案

没有,我不觉得有什么。池线程的方法可能是最务实的。另外,我想你能下降至P / Invoke的 - 但是这将是一个的很多的更多的工作。

No, I don't think there is. The pool thread approach is probably the most pragmatic. Alternatively, I guess you could drop down to P/Invoke - but that would be a lot more work.