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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:46:00+00:00 2026-06-15T13:46:00+00:00

I’m new to do C# Windows Phone programming. In a nutshell, I am currently

  • 0

I’m new to do C# Windows Phone programming.

In a nutshell, I am currently building an app that will:

Load image A

Load image B

and then Load image C

then use these 3 images to do some post processing.

My Image B and Image C are build as Content within the project.
Image A is chosen from Gallery or taken via camera, or we can simply assume that Image A is load from Isolated Storage.

I am experiencing a problem which I believe caused by asynchronous image loading.

Here’s my code:

...
// I intend to load the 3 pictures by calling the method: LoadImage(int id) and LoadCImage();

            else if (ListBox.SelectedIndex == 0)
            {
                Debug.WriteLine("Selected 0");
                PhotoProcessor pp = new PhotoProcessor();
                WriteableBitmap imageA = new WriteableBitmap(AImage);
                WriteableBitmap imageB = LoadImage(0);
                WriteableBitmap imageC = LoadCImage();
                WriteableBitmap mix = pp.Mix(pp.CalcAverageColour(0), imageA, imageB, imageC);
                resultPic.Source = mix;
            }
...

And:

private WriteableBitmap LoadImage(int id)
        {
            //String uriString = "/Assets/img0.jpg";            
            //BitmapImage img = new BitmapImage(new Uri(uriString, UriKind.Relative));
            BitmapImage img = new BitmapImage();
            img.CreateOptions = BitmapCreateOptions.None;
            //img.SetSource(Application.GetResourceStream(new Uri("/Assets/facetemplate0.jpg", UriKind.Relative)).Stream);
            img.UriSource = new Uri("/Assets/img" + id + ".jpg", UriKind.Relative);

            //img.UriSource = new Uri(uriString, UriKind.Relative);
            return new WriteableBitmap(img);
        }

        private WriteableBitmap LoadCImage()
        {
            //BitmapImage img = new BitmapImage(new Uri("/Assets/imgC.jpg", UriKind.Relative));
            BitmapImage bmp = new BitmapImage();
            bmp.CreateOptions = BitmapCreateOptions.None;
            //img.SetSource(Application.GetResourceStream(new Uri("/Assets/imgC.jpg", UriKind.Relative)).Stream);
            bmp.UriSource = new Uri("/Assets/imgC.jpg", UriKind.Relative);
            return new WriteableBitmap(bmp);
        }

Now my question is:

When I’m trying to run this code, it will throw a Null Reference Exception, which is because of the function mix can’t load Image A B and C (loading this images are asynchronously).

I wonder if there’s a way to let me sequentially load these images then let me to pass them to the mix function?

What I’ve tried:

  1. By checking this great blog post, I’m able to know that there do have some way to load the image synchronously, but as you can see throughout my code, I tried to use SetSource(stream) like the blogpost, but unfortunately I got the same Null Reference Exception.

  2. I’ve also thought about the EventHandler method, however I don’t think its a good idea in this case. If I implement EventHandler, would it be something like(pseudo code):

    imageA_Opened()
    {
    LoadImageB += imageB_Opened();
    }
    
    imageB_Opened()
    {
     LoadImageC += imageC_Opened();
    }
    
    imageC_Opened()
    {
    PhotoProcessor pp = new PhotoProcessor();
    pp.Mix(averageColour, A, B, C);
    }
    

Am I right?

  • 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-15T13:46:01+00:00Added an answer on June 15, 2026 at 1:46 pm

    You’re not supposed to be able to download an image sequentially. It would certainly be easier to develop, yes, but it wouldn’t be nearly as effective because you would be blocking the processor for an extended period of time, thus freezing your application.

    I’ve also thought about the EventHandler method, however I don’t think its a good idea in this case. If I implement EventHandler, would it be something like (pseudo code):

    Yep, it would follow that general pattern as you have described it. That’s the appropriate way to address this problem.

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need a function that will clean a strings' special characters. I do NOT
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

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.