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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:12:43+00:00 2026-06-11T18:12:43+00:00

I have the following method where I pass a InMemoryRandomAccessStream loaded with JPEG data:

  • 0

I have the following method where I pass a InMemoryRandomAccessStream loaded with JPEG data:

private async Task<byte[]> GetDataAsync(IRandomAccessStream stream)
{
    BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);

    BitmapFrame frame = await decoder.GetFrameAsync(0);

    BitmapTransform transform = new BitmapTransform()
    {
        ScaledWidth = decoder.PixelWidth,
        ScaledHeight = decoder.PixelHeight
    };

    PixelDataProvider pixelData = await frame.GetPixelDataAsync(BitmapPixelFormat.Rgba8, BitmapAlphaMode.Straight, transform, ExifOrientationMode.IgnoreExifOrientation, ColorManagementMode.DoNotColorManage);

    return pixelData.DetachPixelData();
}

This method hangs all the time except if I put a breakpoint to the first line and step over each line. I tried to use different JPEG images, modify the parameters of “GetPixelDataAsync” and temporary insert “await Task.Delay(…)” between lines, but nothing helps. The App performs a lot of other time consuming asynchronous operations and works fine except for this part. It is unclear why setting a breakpoint (except that it gives some time delay) makes it work.

Please help to solve this problem.

  • 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-11T18:12:45+00:00Added an answer on June 11, 2026 at 6:12 pm

    I guess in the wild, but I had the same problem.

    I think you call this async method from a sync context like:

    private void ButtonClick(...) 
    {
      var bytes = GetDataAsync(...);
    }
    

    This will cause your application to run in the UI Thread which causes a deadlock. Either make the calling method async, too, which will work or use ConfigureAwait(false):

    private async Task<byte[]> GetDataAsync(IRandomAccessStream stream)
    {
        BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream).AsTask().ConfigureAwait(false);
    
        BitmapFrame frame = await decoder.GetFrameAsync(0).AsTask().ConfigureAwait(false);
    
        BitmapTransform transform = new BitmapTransform()
        {
            ScaledWidth = decoder.PixelWidth,
            ScaledHeight = decoder.PixelHeight
        };
    
        PixelDataProvider pixelData = await frame.GetPixelDataAsync(BitmapPixelFormat.Rgba8, BitmapAlphaMode.Straight, transform, ExifOrientationMode.IgnoreExifOrientation, ColorManagementMode.DoNotColorManage).AsTask().ConfigureAwait(false);
    
        return pixelData.DetachPixelData();
    }
    

    Maybe take a look here at this very nice explanation of using async/await and getting deadlocks.

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

Sidebar

Related Questions

I have following code and i want to pass additional parameter in JSON.getJSONfromURL() method
If I have the following method; private TSource CopyFileClientModel<TSource>(TSource fileClientOrContact) So into this method
Suppose I have the following method. def create_multiple project = Project.find(params[:project]) params[:tasks].each_value { |task|
I have following method: private <U> void fun(U u) throws JAXBException { JAXBContext context
I have the following method I can pass in a lambda expression to filter
I'm working with JPA 2 and have the following method: private static void wipeTable(EntityManager
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of
I have following method which I am using to load ActiveX control dynamically, Dim
I have the following method, which takes in the name of a file as
I have the following method that returns void and I need to use it

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.