async-workflow

[F#] Parallelize code in nested loops

You always hear that functional code is inherently easier to parallelize than non-functional code, so I decided to write a function which does the following: Given a input of strings, total up the number of unique characters for each string. So, given the input [ "aaaaa"; "bbb"; "ccccccc"; "abbbc" ], our method will returns a: 6; b: 6; ...

Async Workflows in F#

I am a C# programmer, but I have a question about Async Workflows in F#. Supposing I have the following class in a C# class library: class File { IAsyncResult BeginReadAll(string fileName, AsyncCallback callback, object state){} string EndReadAll(IAsyncResult result){} } My understanding is that is possible in F# for me to make a f...

[F#] Best practices to parallelize using async workflow

Lets say I wanted to scrape a webpage, and extract some data. I'd most likely write something like this: let getAllHyperlinks(url:string) = async { let req = WebRequest.Create(url) let! rsp = req.GetResponseAsync() use stream = rsp.GetResponseStream() // depends on rsp use reader =...

Is there an async version of DirectoryInfo.GetFiles / Directory.GetDirectories in dotNet?

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. Problem is I'm trying to suck in a bunch of directories, probably on SMB mounts over slow network connections, and I don...

How to keep asynchronous parallel program code manageable (for example in C++)

I am currently working on a server application that needs to control a collection devices over a network. Because of this, we need to do a lot of parallel programming. Over time, I have learned that there are three approaches to communication between processing entities (threads/processes/applications). Regrettably, all three approaches ...

f# async web request, handling exceptions

I'm trying to use async workflows in f# to fetch several web requests. However, some of my requests are occasionally returning errors (e.g. http 500), and I don't know how to handle this. It appears like my f# program gets stuck in an infinite loop when running in the debugger. I'm probably missing some stuff, cause examples I seen did...

Let! executing in sequence?

I was under the impression that let! in f# was smart enough to excute sequences of assignments in parallell. However, the following sample displays a different behavior, assignment of a,b,c seems to execute synchronously. let sleep sec = async { System.Threading.Thread.Sleep(sec * 1000) ...