Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 359545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:24:14+00:00 2026-05-12T12:24:14+00:00

Providing Synchronous and Asynchronous versions of Method in c# asks how to provide an

  • 0

Providing Synchronous and Asynchronous versions of Method in c# asks how to provide an async version of a method.

One of the answers suggests that class library developers should avoid providing the async method, if possible, based on the single responsibility principle.

  1. Is this true?
    Should I NOT provide async versions of methods?

  2. If the answer is NO (in other words, DO provide async versions of methods), then should I follow the advice in this MSDN article, which states:

The IAsyncResult design pattern allows for a variety of programming models, but is more complex to learn and provides a flexibility that most applications do not require. Where possible, class library designers should implement asynchronous methods using the event-driven model. In some cases the library designer should also implement the IAsyncResult based model.

??

The “Event driven model” is one where , if the synchronous version of the method is Verb(), the async version of the method is VerbAsync(), and there is a VerbCompleted event.
The IAsyncResult pattern is the well-known BeginVerb() and EndVerb() approach.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:24:15+00:00Added an answer on May 12, 2026 at 12:24 pm

    Why are you considering providing an asynchronous API?

    Are the API operations IO bound or CPU bound? (is the reason it takes a long time because of waiting for IO to complete, or just it’s CPU intensive?)

    If CPU bound, I would consider whether it really is necessary to provide an asynchronous version, since the caller can always effectively convert a synchronous operation into an asynchronous operation via the threadpool.

    The strongest reason for providing an asynchronous API is for operations which are IO bound. Rather than tying up threads to wait on high latency IO operations it is preferable that asynchronous IO is used. This can particularly affect the scalability of a system. For example, if you had a server blocking on a single synchronous IO operation, it’s not too much of an issue – you’re just tying up one thread. However, execute 1000 of the same operation concurrently and you’re tying up 1000 threads (and if memory serves 1MB per thread for stack) just to wait on completion of operations which take few CPU cycles. End result – you’ve got an idle CPU but are sucking up resources.

    So, if for example, you yourself were writing a socket library, for sure you would want to provide asynchronous IO operations, so that users of the library could write scalable applications.

    If, for example, you’re writing an encryption library, then even though the operations may take a long time, there’s probably no pressing need to provide an async API – it’s CPU bound anyway. And as mentioned the user can make it asynchronous.

    Finally, if you’re writing an IO bound system which uses lower level APIs that provide asynchronous IO (e.g. an FTP client that uses the socket classes) you may also want to consider providing an asynchronous version of your API. The thing is though doing this isn’t easy – you only provide the scalability benefit if you make use of the lower level API’s asynchronous functions. This can quickly end up turning simple synchronous logic into extremely complex, difficult to debug asynchronous logic. The main issue being all the state information you previously had nice simple access to via local variables end up needing to be manually captured so that when the next IO operation completes your logic knows what to do next.

    Providing an asynchronous API which then makes calls internally to synchronous IO operations is kind of pointless (though I’ve seen it done). Gives the illusion of scalability, but… isn’t!

    When .NET 4.0 comes out, some of this may get a bit simpler (though I think from what I’ve seen it’s still going to be tricky).

    In the mean time, you might want to check out Jeffrey Richter’s async enumerator library which can help simplify this (somewhat):

    Jeffrey Richter on his async enumerator

    Power threading library including async enumerator

    Hope this helps,
    Phil.

    NOTE: If you are going to implement an asynchronous API, I would recommend providing it via the ‘classic begin/end’ IAsyncResult API. The reason is, from what I remember, it should integrate much better with .NET 4.0’s task parallel library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 252k
  • Answers 252k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Apparently you want to add child objects to your BaseComponent.… May 13, 2026 at 9:43 am
  • Editorial Team
    Editorial Team added an answer Set the width of the panels not in the ASP.NET… May 13, 2026 at 9:42 am
  • Editorial Team
    Editorial Team added an answer An alternative to manually saving to a file is to… May 13, 2026 at 9:42 am

Related Questions

Quick question here: is there any obvious benefit to use asynchronous communication with the
I just wondered why, unlike Scala, F# or Haskell, the basic .NET framework (as
My team and I are designing a diagnostic test tool as part of our
I am loading some assemblies at run time and invoking methods on them using

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.