[英]F# AsyncWaitOne and AsyncReadToEnd
I am working ti old F# code from Expert F# . 我正在使用Expert F#的旧F#代码。 However, the example doesn't build anymore. 但是,该示例不再构建。 The following two calls don't seem to exist: 以下两个调用似乎不存在:
semaphore.AsyncWaitOne(?millisecondsTimeout=timeout)
and 和
reader.ReadToEndAsync()
Does anyone know what these have been replaced with or if I am just missing a reference? 有谁知道这些已被替换或如果我只是缺少一个参考?
It's now called Async.AwaitWaitHandle
. 它现在称为Async.AwaitWaitHandle
。
AsyncReadToEnd
is in the F# PowerPack . AsyncReadToEnd
位于F# PowerPack中 。
By now, FSharp PowerPack project has been broken up into smaller modules for any further development. 到目前为止,FSharp PowerPack项目已被分解为更小的模块,以便进一步开发。 Specifically, the AsyncStreamReader class and the extension methods for the reading from a StreamReader, WebClient, etc. the new project is FSharpx.Async . 具体来说,AsyncStreamReader类和从StreamReader,WebClient等读取的扩展方法新项目是FSharpx.Async 。
1) AsyncWaitOne is now called Async.AwaitWaitHandle
. 1)AsyncWaitOne现在称为Async.AwaitWaitHandle
。
2) AsyncReadToEnd()
extension method does not exists anymore in the FSharp.PowerPack . 2) AsyncReadToEnd()
扩展方法中不存在了FSharp.PowerPack 。 It has been replaced with the AsyncStreamReader
dedicated type that contains proper asynchronous implementation of stream reading (like ReadToEnd
, ReadLine
, etc.) 它已被AsyncStreamReader
专用类型所取代,该类型包含正确的流读取异步实现(如ReadToEnd
, ReadLine
等)
It can be used like that: 它可以这样使用:
async {
use asyncReader = new AsyncStreamReader(stream)
return! asyncReader.ReadToEnd() }
Note: Once you have installed FSharp.PowerPack , the AsyncStreamReader
type will be 'injected' in the Microsoft.FSharp.Control
namespace 注意:安装FSharp.PowerPack后 , AsyncStreamReader
类型将在Microsoft.FSharp.Control
命名空间中“注入”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.