JavaScript mini TPL library: RunAsync

Having learned about HTML5 Web Worker functionality, and that most of the modern browsers implement it, together with the File API BlobBuilder capability I thought about building a library that resembles C#’s Task Parallel Library, allowing JavaScript to be executed in a background thread, but at the same time, adding the ability to dispatch execution to the UI thread and also invoke callbacks and continuations to a “task”. I figured the dispatcher functionality was important since usually whatever is executed in the background can/probably will need to interact with the UI while executing. Also this opens a door to use UI frameworks such as jQuery and/or any other DOM access. The problem of passing state while dispatching to the UI thread still exists, but it’s on my queue to be solved.

Do check GitHub’s page: 


Dispatch execution to the UI thread (from within a or continueWith function callback):


Running code synchronously


JCrop + Thickbox iframe + Internet Explorer 8 (Nasty IE bug fix)

Hello guys.
Before posting about .NET Framework 4.0, I have to tell you about an episode (another one) about the horrifying experience that is programming IE compatible javascript.
The scenario:

I have a web form with a input file, that I need to crop & resize the image (if it is one), on a thickbox iframe.

So I create submit my form to an iframe, and when the iframe is loaded, I run the JCrop plugin.
So far so good..on Firefox..
Then I test this on IE8, nothing, the image doesn’t appear or the image appears, but no JCrop functionality whatsoever, and why? Because IE8 (an 7 as far as I know) doesn’t load the image in a timely fashion, or when it’s supposed to be loaded! Nothing works! window load event, image load event, document ready, document load, nothing!

The Trick: having the jcrop call inside a setTimeout, with 1 ms only…

It’s a shame on 2010 we still need to hack to get things working on IE.

Hope this save you a good couple of yours, like it would if I had it.