As a Web Developer, I’ve frequently have had the need to make asynchronical function calls.
Usually, you need to do async calls when:
- Function takes a long time to process
- There is no need to present a response to the user
In this example, I will be showing some code I use on my Facebook Application (Network Trotters) to update the users profiles.
As a quick contextual background, user profiles are cached on Facebook’s side, and periodically I need to clear the cache so it is updated. This action can take a bit of time when you have a high number of users, but it doesn’t really require any response to the user.
There are 3 main things you need to do to create an async call:
- Create a delegate with the signature you would like
- Implement a Function with the same function as the delegate
- Call the delegate