dotNet 中是否有 DirectoryInfo.GetFiles/Directory.GetDirectories 的异步版本? [英] Is there an async version of DirectoryInfo.GetFiles / Directory.GetDirectories in dotNet?

查看:24
本文介绍了dotNet 中是否有 DirectoryInfo.GetFiles/Directory.GetDirectories 的异步版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

这篇关于dotNet 中是否有 DirectoryInfo.GetFiles/Directory.GetDirectories 的异步版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆