Wednesday, March 30, 2016

Why method that return a Task should end with Async

I have spoken before about using the Fleck WebSocket server library for .NET, but recently I experienced a small problem with it. Pull request #126 changed several public methods to become async and return a Task instead of void.

This did not follow the recommended naming convention of naming all async methods with the Async suffix.

In my case, this caused us to introduce a bug to a project that was using Fleck. We would ignore Task returned from IWebSocketConnection.Send, and under high load the task scheduler would get backed up.

Even though I do not think that they are going to use it, I created a pull request that updated the the public methods to include the Async suffix. Also, in order to maintain backwards compatibility, I also added obsolete methods to the interfaces without the suffix.

What did I do with the tasks? Rather than write in parallel, I used a concurrent queue and had a background task serially write messages to the connection.

Enjoy,
Tom

9 comments:

  1. have to say that during my time browsing through the internet I have read many articles/ Blogs but yours particularly have impressed me how you have written this masterpiece is mind-blowing. Kindly visit my website for new and latest Cracks : Wondershare AllMyTube

    ReplyDelete

  2. I am very happy to read this article. Thanks for giving us Amazing info. Fantastic post.
    Thanks For Sharing such an informative article, Im taking your feed also, Thanks.design-doll-serial-key/

    ReplyDelete
  3. I was looking for this information from enough time and now I reached your website it’s really good content.
    Thanks for writing such a nice content for us.
    2018/10/18/windows-8-1-product-key

    ReplyDelete
  4. Really Good Work Done By You...However, stopping by with great quality writing, it's hard to see any good blog today.
    KaliCrack
    Free YouTube Download Premium CRACK
    Crack Softwares Free Download

    ReplyDelete
  5. I am very happy to read this article. Thanks for giving us Amazing info. Fantastic post.
    Thanks For Sharing such an informative article, Im taking your feed also, Thanks.
    red-giant-universe-crack/

    ReplyDelete
  6. Hi Dear, I like your post style as it’s unique from the others. I’m seeing on the page.
    IDM

    ReplyDelete
  7. Really Good Work Done By You...However, stopping by with great quality writing, it's hard to see any good blog today.
    fullzversionpro.org
    WBS Schedule Pro CRACK
    Crack Softwares Free Download

    ReplyDelete
  8. I am very happy to read this article. Thanks for giving us Amazing info. Fantastic post.
    Thanks For Sharing such an informative article, Im taking your feed also, Thanks.visible-body-anatomy-and-physiology-crack/

    ReplyDelete

Real Time Web Analytics