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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:41:21+00:00 2026-05-27T07:41:21+00:00

I am trying to use webclient check download a stream before it is handled

  • 0

I am trying to use webclient check download a stream before it is handled by an ExtendedImage, because my app is showing a bug when the uri is not found.

So my solution is to load the image first and then read the webclient result into the extended image.

This is what I am trying to do.

WebClient wc = new WebClient();
wc.OpenReadAsync(Uri);

wc.OpenReadCompleted += delegate(object Sender, OpenReadCompletedEventArgs e){
        Logo = new BitmapImage();
        ExtendedImage hExtendedImage = new ExtendedImage();

        try
        {
                hExtendedImage.SetSource(e.Result);
                Logo.SetSource(hExtendedImage.ToStream());
        }
        catch (WebException)
        {

        }
};

but now I am getting an “image is not loaded” error from hExtendedImage on this line

Logo.SetSource(hExtendedImage.ToStream());

I’m obviously loading the image from e.Result into the hExtendedImage wrong.

  • 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-27T07:41:22+00:00Added an answer on May 27, 2026 at 7:41 am
    var client = new WebClient();
    
    // Always define event handlers, 
    // BEFORE calling any method that could invoke them.
    client.OpenReadCompleted += (s1, e1)
    {
        Logo = new BitmapImage();
    
        var extendedImage = new ExtendedImage();
        extendedImage.OnLoadingCompleted += (s2, e2)
        {
            // Invoke the dispatcher, so we're sure it's set on the UI thread.
            Dispatcher.BeginInvoke(new Action
            (
                () => Logo.SetSource(extendedImage.ToStream()))
            );
        };
        extendedImage.SetSource(e1.Result);
    };
    
    client.OpenReadAsync(Uri);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the WebClient class to download a html file from another
I'm trying to use WebClient to download a bunch of files asynchronously. From my
I am trying use a Java Uploader in a ROR app (for its ease
I am trying to use System.Net.WebClient in a WinForms application to upload a file
Can someone please tell why, when I use WebClient in C# to download a
I am trying to download a file using webclient in c#. the remote port
I'm trying to download the source HTML of a website using the WebClient.DownloadData() method.
I am trying to use the webclient module to query the couchDB rest interface
I was trying use a set of filter functions to run the appropriate routine,
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on

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.