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

  • Home
  • SEARCH
  • 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 7508107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:37:17+00:00 2026-05-29T22:37:17+00:00

The .NET 4.5 framework libraries integrate C#-style Task-based async fairly extensively. In many cases,

  • 0

The .NET 4.5 framework libraries integrate C#-style Task-based async fairly extensively. In many cases, they also continue to expose APM-style Begin/End method pairs. F# can easily adapt either method to F#-style asynchronous computations.

My question is, given an IO-bound operation that’s implemented in the framework as both Begin/End and Task-based async, is there a performance or memory advantage to choosing one over the other when adapting to F# async?

For example, in .NET 4.5, System.IO.Stream has both BeginRead and ReadAsync. That means I can do this…

type System.IO.Stream with
    member x.AsyncRead(buffer, offset, count) =
        Async.FromBeginEnd(buffer, offset, count, x.BeginRead, x.EndRead)

Or I can do this…

type System.IO.Stream with
    member x.AsyncRead(buffer, offset, count) =
        x.ReadAsync(buffer, offset, count) |> Async.AwaitTask

Is there any reason to prefer one over the other? The main difference that I can think of is that the read operation will have already started when the second extension method returns, but not so with the first extension method.

  • 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-29T22:37:17+00:00Added an answer on May 29, 2026 at 10:37 pm

    An AsyncRead extension method (implemented in terms of FromBeginEnd) is already defined in FSharp.Core. AwaitTask is just a thin wrapper over Task.ContinueWith. So it boils down to a comparison of Task and async–which is more efficient, or right for the job. Since you’re working with asyncs, the only relevant difference would be performance. I’m not an expert on this, but I think async and Task address the same issue, with Task having an edge for CPU-bound operations.

    EDIT

    I didn’t read your question carefully enough. I don’t know the definitive answer, but given that Task and async are roughly equivalent, I don’t see any reason to wrap a Task with an async unless it’s your only option. Begin/End methods are a lower-level, more lightweight abstraction, and therefore seem like better building blocks for asyncs.

    An ancillary thought: the fact that AsyncRead wasn’t changed to use Task could be instructive.

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

Sidebar

Related Questions

Any good logging libraries that support .NET compact framework?
.NET Framework 3.5 comes with all the LINQ goodies, and also includes predefined generic
In .net framework. what are libraries available for working in sharepoint and their uses
I couldn't find aes libraries in .net framework. Is there any external libraries? thanks
.NET Framework: 2.0 Preferred Language: C# I am new to TDD (Test Driven Development).
.NET framework 3.5 introduces Action and Func<> predefined delegate types that are very handy.
The .net framework includes Math.IEEERemainder(x, y) in addition to the standard mod operator. What
In .NET framework, is it possible to set some of the items in the
The .net framework provides in the Math class a method for powering double. But
The .NET framework ships with 6 different hashing algorithms: MD5: 16 bytes (Time to

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.