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 8356647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:15:02+00:00 2026-06-09T10:15:02+00:00

I have one asynchronous method: public async Task<BitmapSource> GetBitmapAsync(double[] pixels); Let’s say I also

  • 0

I have one asynchronous method:

public async Task<BitmapSource> GetBitmapAsync(double[] pixels);

Let’s say I also have this class:

public class PixelData
{
    public double[] Pixels { get; }
}

I now want to create a convenience method producing a BitmapSource output, using the asynchronous method above to do the work. I can come up with at least three approaches to do this, but it is not immediately obvious to me which one I should choose from an efficiency and reliability point of view.

Can someone advice; what are the advantages and drawbacks of each one of the following approaches?

Option A Create a synchronous method that returns the Result of the Task:

public BitmapSource GetBitmap(PixelData pixelData)
{
    return GetBitmapAsync(pixelData.Pixels).Result;
}

Option B Create a synchronous (or is it asynchronous?) method that returns Task<BitmapSource>:

public Task<BitmapSource> GetBitmap(PixelData pixelData)
{
    return GetBitmapAsync(pixelData.Pixels);
}

Option C Create an asynchronous method that explicitly uses await:

public async Task<BitmapSource> GetBitmapAsync(PixelData pixelData)
{
    return await GetBitmapAsync(pixelData.Pixels);
}
  • 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-06-09T10:15:04+00:00Added an answer on June 9, 2026 at 10:15 am

    I think you’re over-thinking this.

    You’ve got a method that returns a type that happens to be a Task<T>. You want a method that takes a different type of parameter and passes through to the original method. So Option B is fine:

    public Task<BitmapSource> GetBitmap(PixelData pixelData)
    {
        return GetBitmapAsync(pixelData.Pixels);
    }
    

    The method should be called GetBitmapAsync though.

    Option A would be the way to expose a synchronous ( blocking ) version of the method.

    Option C doesn’t actually achieve anything more than Option B.

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

Sidebar

Related Questions

I have a public async Task Foo() method that I want to call from
I have a basic asynchronous task that performs a web request. The thread is
I have already one thread that has to do following work: public class DetectionHandler
I want to provide a task-based asynchronous pattern-style method. When awaiting the method, I
I have a one main Workflow which calls several activities asynchronously. Some of the
have one time consuming step that flattens a bunch of files. basically i'd like
I have one XML request which I need to modify (to XML) and then
I have one user (only one, all the others are fine) trying to update
I have one repo hosted at https://github.com/aikiframework/json . On my local copy, I added
I have one drop down list in my page, which contains two options. What

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.