How do I play audio files synchronously in JavaScript?

Do not use HTMLAudioElement for that kind of application. The HTMLMediaElements are by nature asynchronous and everything from the play() method to the pause() one and going through the obvious resource fetching and the less obvious currentTime setting is asynchronous. This means that for applications that need perfect timings (like a Morse-code reader), these elements … Read more

Can AFNetworking return data synchronously (inside a block)?

To block the execution of the main thread until the operation completes, you could do [operation waitUntilFinished] after it’s added to the operation queue. In this case, you wouldn’t need the return in the block; setting the __block variable would be enough. That said, I’d strongly discourage forcing asynchronous operations to synchronous methods. It’s tricky … Read more

How do I make an eventhandler run asynchronously?

So you want to raise the event in a manner that prevents the listeners from blocking the background thread? Gimme a couple minutes to whip up an example; it’s pretty simple 🙂 Here we go: first an important note! Whenever you call BeginInvoke you must call the corresponding EndInvoke, otherwise if the invoked method threw … Read more

Are all javascript callbacks asynchronous? If not, how do I know which are?

I’m curious as to whether all javascript callbacks are asynchronous No. For instance, the callback used by Array#sort is not asynchronous, nor is the one used by String#replace. The only way you know whether a callback is asynchronous is from its documentation. Typically, ones involving requests for external resources (ajax calls, for instance) are asynchronous, … Read more

When to use JMS and when to use REST? [closed]

Always use REST. It is the most modern, advanced and scalable integration approach available today. Load balancing a REST based service is achieved simply with hardware or software HTTP load balancer and can be considered just as free as load balancing in JMS. MOM (Message Oriented Middleware) doesn’t scale easily (but may scale big enough … Read more

Data doesn’t load in UITableView until I scroll

Put this somewhere after the data is loaded successfully: dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView reloadData]; }); This fix the problem of calling a GUI update while you’re not in the main thread. This code uses the GCD Technology from Apple to force the reload data function to run on main thread. Read more about Concurrency Programming Guide … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)