F#: Erlang style messaging passing

As I mentioned in my previous post about over loading methods in F# I’ve been trying to refactor my twitter application into a state where it can concurrently process twitter statuses while continuing to retrieve more of them from the twitter website.

I played around a bit with Erlang last year and one thing that I quite liked is the message passing between processes to allow operations to be performed concurrently.

The reason for me wanting to do this is because the twitter API only allows me to retrieve 20 statuses at a time and if I’m getting a large number of them my original design means that we are just waiting for the statuses to be accumulated before we can do anything else with them - I want to make this a bit more real time.

There is certainly some duplication in there - I think it should be possible to get a BaseMailboxProcessor - and I found it annoying that I needed to have a different type of mail box processor for each of the cases so that I could have different pattern matching in each.

In Erlang that scaffolding is built into the language and you just need to care about the pattern matching which is the important thing here.

I’ve setup a callback function that’s passed to the LinkProcessor which prints out the status when it processes it. The next step is to store that somewhere so I can view them later.

Running this though the threadId is always the same. The console output looks like this: