Extension Methods

Passing Continuations

Last Time we saw how to perform Actions asynchronously and I promised to talk about continuations. Continuations also known as CPS or Continuation Passing Style is a mechanism for passing in code that would normally execute after a function call to the callee function as an argument, perhaps most well known in Scheme. For example if you were to call a function Sum which returns an int and print out the result like so: public static int Sum(int n) { //sure we could use (n*(n+1))/2 but this is just...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Performing multiple Asynchronous Actions for long running operations

The Action delegate in .NET is pretty handy when you need to invoke a method that takes no arguments. You assign the method name or an anonymous delegate/lambda to an Action delegate variable and just call the delegate variable to have your method invoked. But, what if you needed to invoke multiple actions simultaneously or wait for all actions to complete before the main thread can proceed? Maybe these actions are responsible for pre-fetching data from a service that the main thread requires or...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati