r/javascript • • Oct 29 '10

c# programmer: JavaScript is "completely single threaded and blocking" in relation to fetching from a URL.

/r/programming/comments/dxv7a/asynchrony_in_c_5_part_one/c13rj6k
0 Upvotes

26 comments sorted by

View all comments

21

u/ruinercollector Oct 29 '10

You are an idiot.

-12

u/Not_Edward_Bernays Oct 29 '10

no, I am still fucking right. the browser does not block while downloading data for AJAX. that's what I said, that's what you all have confirmed. what they are trying to achieve in that C# example is something javascript in the browser does without any weird code. so it is exactly as I characterized it, especially in this example, they are trying to catch up with javascript.

I never said the UI code runs on multiple threads.

if I could have less respect or more animosity towards you pieces of shit I would.

5

u/darrenkopp Oct 29 '10

I take it you haven't heard of BeginInvoke and EndInvoke?

Action a = new Action(() => {
    // some blocking operation
});

// run async, invokes callback when done
a.BeginInvoke(cb => a.EndInvoke(cb), null);

This is no different than the javascript example. You start something executing, and when it's done, it calls a callback. In javascript, the callback is the onreadystatechange callback. They are the exact same in principal, just different in execution.

Also, XmlHttpRequest does not mean asynchronous, it just is by default. you can have a blocking XHR request.

-1

u/Not_Edward_Bernays Oct 29 '10

I did a lot of async programming with begininvoke and such 3 or so years back