I am trying to use asynchronous workflows in F # to receive multiple web requests.
However, some of my requests sometimes return errors (e.g. http 500), and I don't know how to handle this. It looks like my F # program is stuck in an endless loop when working in the debugger.
I probably miss some things because the examples I saw did not compile out of the box. The first thing I found helped in this bit of code:
type System.Net.WebRequest with
member req.GetResponseAsync() =
Async.BuildPrimitive(req.BeginGetResponse, req.EndGetResponse)
and then I have my own piece of code to extract the queries, which is pretty standard from the examples I saw:
let async_value = async {
let req = WebRequest.Create(url)
let! rsp = req.GetResponseAsync()
return (rsp :?> HttpWebResponse).StatusCode
}
and then I will try to get the result:
let status = Async.RunSynchronously(async_value)
, req.EndGetResponse, 500. , , req.EndGetResponse ( ), status = Async.RunSynchronously (async_value).
, ? , , ? /dll F #/VS 2010 Beta 1, ?
, Async.RunSynchronously (Async.Parallel (my_array_of_async_values)), , , .
, , , Async.Run, Async.RunSynchronously, , , ... =/