The Easiest Way To Write Async Code – Reading #FunnelWeblog Code

This one is a Back-To-Basics style post. Last month, I was checking some code for the relatively new .NET open source blog engine, FunnelWeb, and noticed this bit of code:


            SendEmail(settings, commentDetails);

This is just a real easy way to make async call, right?


BTW, you can learn more about the ThreadPool.QueueUserWorkItem() method from MSDN here.


More Interesting Stuff

Playing with it after reading, I found that Matt Valerio seems to have very interesting takes on this method, making you use it in many elegant ways:


I highly recommend the first two articles especially, the code is really elegant.


What IS This Post???

I felt a strong desire to blog something before I go to work today and wanted to see if that’s possible.

Not sure if I should write more posts like this, or am I then converting the blog here to a micro-blog/twitter/tumblr of some kind.

You might help me by telling what you think in the comments.

Share With Friends:

How did I learn that?

As a bonus for coming here, I'm giving away a free newsletter for web developers that you can sign up for from here.

It's not an anything-and-everything link list. It's thoughtfully collected picks of articles and tools, that focus on Angular 2+, ASP.NET (4.x/MVC5 and Core), and other fullstack developer goodies.

Take it for a test ride, and you may unsubscribe any time.

You might also want to support me by checking these out [Thanks]:

  • Thanks Mohamed. Note that if the SendEmail() function threw an exception and it wasn’t caught, it would tear down the AppDomain.

    In WPF applications, I’ll use a try/catch, and in the catch, dispatch to the UI thread and re-throw the wrapped exception. This way, my main UI thread can show the exception details and “handle” the exception so the application keeps running (assuming it is safe to do so).

    In this scenario, if the email isn’t sent, we don’t care too much, so we put a try/catch inside the SendEmail function and swallow any exception to prevent the web application from terminating.