I've covered the asynchronous Fire and Forget pattern several times here and now I want to show a final usage pattern.
Most blogging APIs include the RPC Ping API to ping various RPC servers that you've updated your content. However, this works for any content, not just blog posts or changes in your RSS feed. So, if you have a forums app on your site, you can use it to ask the servers to revisit for a new forum post. Same with a new article, and so on.
Manyy of these RPC ping services have directories that they update. Weblogs.com even has a "rolling update" of links and you can download xml files of the most recent ping updates. A lot of this is legitimately indexed - which can result in increased traffic to your site. Some of it is just mindlessly populated with search results and other more or less "made for Adsense" bogus content, too.
The problem that often occurs with these RPC servers -- and often with many other types of "notification" URLS, be they GET or POST - is that this is a blocking call and you don't know how long it will take to return. For that matter, it might even time out, and in either case you don't want your web pages sitting around waiting, because that creates a really lousy user experience, making it seem like it is your site that is at fault.
So it's FIRE and FORGET to the rescue, once again! What I've done here is to wrap up four different utility methods in the Fire and Forget idiom, all in a nice self-contained class library, all static methods.
All of these methods return immediately; they are not blocking calls:
1) RequestURL - makes a Fire and Forget GET request to any url with optional "stuff" on the querystring.
2) PostToUrl - makes a Fire and Forget HTTP FORM POST to any url with optional querystring. You supply the FORM values in a NameValueCollection.
3) DoPingOMatic - makes a call to the popular Pingomatic.com service with your title and URL. Pingomatic takes care of the rest with its list of RPC servers.
4) DoPings - makes calls to a list of known RPC servers (which you can override with your own in an appSettings section).
In the sample web project that comes with this I also illustrate how to call the Yahoo API to ping the yahoo crawler as it requires a RESTful call which uses my RequestURL method. There is also a CHM Help file for the library included in the /doc folder for the SearchPinger project.
Some sample usage code:
And here is the SearchPinger class: