简体   繁体   中英

F# AsyncWaitOne and AsyncReadToEnd

I am working ti old F# code from Expert 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 .

AsyncReadToEnd is in the F# PowerPack .

By now, FSharp PowerPack project has been broken up into smaller modules for any further development. Specifically, the AsyncStreamReader class and the extension methods for the reading from a StreamReader, WebClient, etc. the new project is FSharpx.Async .

1) AsyncWaitOne is now called Async.AwaitWaitHandle .

2) AsyncReadToEnd() extension method does not exists anymore in the FSharp.PowerPack . It has been replaced with the AsyncStreamReader dedicated type that contains proper asynchronous implementation of stream reading (like ReadToEnd , ReadLine , etc.)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM