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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:53:06+00:00 2026-05-21T19:53:06+00:00

I was hoping somebody could shed some light on a seemingly complex problem I

  • 0

I was hoping somebody could shed some light on a seemingly complex problem I am having with async webclient downloads in silverlight. Here are the details of my problem-

Downloading a multi-page XML web request. Moved the webclient code into a helperclass to track each individual request. The helper class is called SyncJobsClass. Source for this class at (http://www.silvergeek.net/silverlight/running-async-tasks-synchronously-events-delegates/)

Have a download button to start task-

void button1_Click(object sender, RoutedEventArgs E)
{
var req = new RequestClass;
req.GetXMLPages();
}

Here is the request class-

Public Class RequestClass
{
readonly SyncJobsClass _syncJobs = new SyncJobsClass();

Public void GetXMLPages()
{

_syncJobs += new SyncJobsElementCompleted;
_syncJobs += new SycJobsWorkCompleted;

var pages = 10

   for(var i=0;i<10;i++)
   {
      //load each request into list in _syncjobs class
      var url ="www.blahblahblah.com" + i;
      _syncJobs.DownloadFiles(url);

   }
      //start download of each page in list
     _syncJobs.StartDownload();

}


}

So as you can see after this step I have a queue of pages being downloaded asynchronously. As the pages are completed I pass them to a XML Linq formatter then bind the resulting data to my ViewModel.

void SyncJobsElementCompleted(string result)
{

if(result == "error")return;

//send data to XML linq parser and add to observable collection for viewmodel.
App.ViewModel.LoadData(result);


}

The problem is for large downloads if I create a new instance of GetXMLPages() by pressing a download button, the previous download is not completed yet and i get mixed results in the viewmodel. I tried changing the button event to –

void button1_Click(object sender, RoutedEventArgs E)
    {
    var req = new RequestClass;

    //Clear view model before download
     App.Viewmodel.List.Clear()
   // now get pages
    req.GetXMLPages();
    }

Well this does not work since the download is still going in a different thread..

Tried a boolen but that will only be valid for that instance of RequestClass, which gets recreated on each button press..

How can I prevent another download from being started before I create a new request? If you need more details let me know.. Any help would be greatly appreciated.

  • 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-21T19:53:07+00:00Added an answer on May 21, 2026 at 7:53 pm

    I think the boolean is the correct route to go–I’ve run into a similar situation before and used a boolean to solve my problem. You could try storing the boolean in your App class so its not being re-created every time you create a new RequestClass.

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

Sidebar

Related Questions

Having little experience in Opengl es (or opengl) I was hoping somebody could help
I'm having some troubles with using the std::sort algorithm here. I was reading that
I'm having a problem with my MySQL statement. I need a query that counts
I'm having a little problem getting my data to submit. I'm trying to make
Hoping to get some clear advice on this one. I want to push updates
Im hoping you geniuses here at stackoverflow can help me with this. Recently i
Hoping someone can provide an answer with this, although it's not 100% programming related.
I'm hoping there's a way to avoid custom configuration files if an application runs
I'm hoping to find out what tools folks use to synchronize data between databases.
I'm hoping someone has seen this before because I can't for the life of

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.