Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Usage for monadic Future in C#
using System;
using System.Threading;
using XSharpx;
using System.Collections;
using System.Net;
namespace TestProj
class MainClass
public static void Main (string[] args)
Console.WriteLine ("Total Page size for search engines");
var c = new CountdownEvent(1);
//all calls happening concurrently
var googPF = GetPageFuture ("");
var bingPF = GetPageFuture ("");
var ddgPF = GetPageFuture ("");
//now we sequence the results in an easy to read fashion wihtout callbacks
var totalPageSize =
from googlePage in googPF
from bingPage in bingPF
from ddgPage in ddgPF
select googlePage.ToCharArray().Length + bingPage.ToCharArray().Length + ddgPage.ToCharArray().Length;
totalPageSize.Map (s => {
Console.WriteLine ("Total size is = " + s);
return c.Signal();
Console.WriteLine ("At the end of main");
public static Future<String> GetPageFuture (String str)
return Future.Create (()=>GetPage (str));
public static String GetPage (String str)
var ret = "";
using (var client = new WebClient()) {
ret = client.DownloadString (str);
return ret;
Something went wrong with that request. Please try again.