asynchronous

Is this a good way to implement the Asynchronous Programming Model?

I've been on a tear lately trying to learn everything I can about .Net Multithreading. (Getting better at it, but still feel like there's lots to learn). Right now I'm focusing on the APM (Asynchronous Programming Model) which is commonly known as this: //non async method public int DoSomeWork(int arg) { //do something and return res...

Asynchronous programming in JavaScript without messy callbacks

I want to turn an asynchronous function to the synchronous. function fetch() { var result = 'snap!'; $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?", function messyCallback(data){ result = data; }); return result; } document.write(fetch());​ See in action ...

How to execute a function asynchronously every 60 seconds in Python?

Hello, I want to execute a function every 60 seconds on Python but I don't want to be blocked meanwhile. How can I do it asynchronously? import threading import time def f(): print("hello world") threading.Timer(3, f).start() if __name__ == '__main__': f() time.sleep(20) With this code, the function f is execut...

Asynchronous Controller in ASP.NET MVC

Do you have anything more expressive on Asynchronous Controller in ASP.NET MVC? Cheers :) ...

proper way to iterate through data in a class when the data changes asynchronously

I have a C# class which has a dictionary inside it. The class listens asynchronously to messages that, upon arrival and processing, alter the data in the dictionary. What is the "correct" way for an app that uses an instance of this class to iterate through the data in the dictionary? Do I have to wrap it into another class and implemen...

How to sequence events in Actionscript 3

I've been working with AS3 a lot over the last weeks and I've run into a situation that google hasn't been able to help with. The crux of the problem is that before I run a function I need to know that certain conditions have been met, for example loading my config.xml and putting it into a class variable. Where I run into trouble is tha...

WCF: Is it safe to spawn an asynchronous worker thread on the server?

I have a WCF service method that I want to perform some action asynchronously (so that there's little extra delay in returning to the caller). Is it safe to spawn a System.ComponentModel.BackgroundWorker within the method? I'd actually be using it to call one of the other service methods, so if there were a way to call one of them asynch...

Interrupting epoll_wait with a non-IO event, no signals

Current scenario is epoll_wait over a couple of fds and a queue of possible incoming messages, I'd like the loop below epoll_wait to be executed on IO event or on new message. Ways I know: Use a time msec timeout and check the queue first thing in the loop Use the self-pipe trick from the queue code when messages become available Int...

Is it possible to do asynchronous / parallel database query in a Django application?

I have web pages that take 10 - 20 database queries in order to get all the required data. Normally after a query is sent out, the Django thread/process is blocked waiting for the results to come back, then it'd resume execution until it reaches the next query. Is there's any way to issue all queries asynchronously so that they can be ...

Catching exceptions thrown in an asynchronous web service completed event handler

Imagine a web service with a method that returns a Customer object, that takes a customer ID as a parameter, i.e. [WebMethod] Customer GetCustomer(string customerId) Now imagine that you're writing an ASP.NET app and you've generated a proxy for the service with the async operations. You create an instance of the service, wire servic...

Spring Async RMI Call

Is it possible to invoke Java RMI asynchronously? I'd like my RMI call to return immediately and for the server to invoke a callback once a task is completed. I'd currently using RMI support from Spring framework, and i couldn't find any documentation describing it in spring, I suspect I'll need to implement it myself. Please provid...

Asynchronous/parallel HTTP requests using PHP curl_multi

I recently looked into the possibility of making multiple requests with curl. I may not be understanding it fully, so I am just hoping to clarify some concepts. It's definitely a good option if you are fetching content from multiple sources. That way, you can start processing the results from faster servers while still waiting for slowe...

Is there a generic way to synchronize an asynchronous method?

We have this common scenario where we have a method that performs some action asyncronously and raises an event when it's done. There are times where we want it done synchronously instead so we have code that looks similar to this: ManualResetEvent reset = new ManualResetEvent(false); someobject.AsyncActionDone += (sender, args) => r...

How to Access web service method Asynchronously ?

I am consuming a web service. I wanna call its method asynchronously. I called method asynchronouly but results are not returned. I call the method like: search.BeginGetData("DEMO", 1, 1, 0, 200000, 1, New AsyncCallback(AddressOf Responder), search) My method is: Private Sub Responder(ByVal Result As IAsyncResult) Dim s As Prop...

ASP.NET, asynchronous call to another page, return response immediately

Hi all! The problem is as follows: An external server sends incoming SMS messages converted to HTTP requests into my sometimes very time-consuming .aspx page. If no response is returned to the external server in 20 seconds, this is considered as an timeout and the same message is sent to my aspx page again (and maybe again....) The opt...

Help eliminate loop in asynchronous receiver due to content-length = 0 in HTTP response

Some web servers return content-length set to zero in the HTTP response headers. I'd like a deterministic and performant solution for receiving all the data in that situation. URL known to exhibit this behavior (additional URLs below): http://www.washingtonpost.com/wp-dyn/content/article/2010/02/12/AR2010021204894.html?hpid=topnews he...

What's the best approach to asynchronous image caching on the iPhone?

I'm creating an iPhone app that will pull data down from a Web API, including email addresses. I'd like to display an image associated with each email address in table cells, so I'm searching the Address Book for images and falling back on a default if the email address isn't in the book. This works great, but I have a few concerns: Pe...

What mutex/locking/waiting mechanism to use when writing a Chat application with Tornado Web Framework

We're implementing a Chat server using Tornado. The premise is simple, a user makes open an HTTP ajax connection to the Tornado server, and the Tornado server answers only when a new message appears in the chat-room. Whenever the connection closes, regardless if a new message came in or an error/timeout occurred, the client reopens the ...

CFHost DNS Resolution - When is it OK to use synchronous API?

I went to the iPhone Developer Tech Talk a few months ago and asked one of the gurus there about the lack of NSHost on the iPhone. Some code I was porting to the iPhone made significant use of NSHost throughout its networking code. I was told that NSHost is on the iPhone, but its private. I was also told that NSHost is a synchronous API...

How to use UDDI's asynchronous subscription service from a client?

How might one go about implementing the client side for jUDDI v3 asynchronous subscription to listen for business entities to be added or deleted? My understanding is that a subscription is created and then jUDDI somehow calls a webservice. How do I create a subscription that points back to my webservice? I've looked through the tutoria...