Very simple usage, this is simply a static field which has a default implementation of dispatching a action to the UI Thread.
Usage: Execute.OnUIThread(()=> { /* will execute on UI Thread */ })
To Unit Test: Execute.OnUIThread = a=>a(); //Replace implementation so it simply executes on current thread

Execute.AsyncPattern & Execute.AsyncPatternWithResult

var stream = new MemoryStream();
var buffer = new byte[0];
const int offset = 0;
const int count = 0;
var bytesRead = Execute.AsyncPatternWithResult(stream.BeginRead, buffer, offset, count, stream.EndRead);

This is a pretty bad example, but you get the idea.


        var foo = Execute.AsyncPatternWithResult(webservice.BeginGetFoo, 123, webservice.EndGetFoo);
        return Execute.AsyncPatternWithResult(webservice.BeginGetBar, foo, webservice.EndGetBar);
        if (r.HadError)
            throw e.Error;

The use of Execute and Background worker aims to simplify certain scenarios quite easily, obviously don't use Execute.AsyncPattern on the UI Thread or anything silly like that :P

Last edited Jun 10, 2011 at 5:26 AM by JakeGinnivan, version 2


No comments yet.