How to achieve Asynchrony instead of Parallelism in F#

后端 未结 5 1834
无人共我
无人共我 2021-02-08 23:24

(Sticking to a common example with async fetch of many web pages)

How would I spin off multiple (hundreds) of web page requests asynchronously, and then wait for all req

5条回答
  •  灰色年华
    2021-02-08 23:37

    I'm not an F# guy, but from a pure .NET perspective what you're looking for is TaskFactory::FromAsync where the asynchronous call you'd be wrapping in a Task would be something like HttpRequest::BeginGetResponse. You could also wrap up the EAP model that WebClient exposes using a TaskCompletionSource. More on both of these topics here on MSDN.

    Hopefully with this knowledge you can find the nearest native F# approach to accomplish what you're trying to do.

提交回复
热议问题