Backgroundworker Problem

Hi, I have a problem. Im using a backgroundworker object to do some processing, but the dowork method is not executing properly.
When debugging, the debugger goes to the first line of code in
the method, and does not move on.

Can anyone give me some insight
Here's the code:

{

int current = 0;

localhost.Photo[] photos = galleryService1.GetPhotos( CurrentGalleryID);

current = 0;

foreach (localhost.Photo photo in photos)

{

System.Net.WebResponse response = System.Net.WebRequest.Create(ImageHandlerLocation + "Size=100&ImageID=" + photo.PhotoID.ToString()).GetResponse() as System.Net.WebResponse;

CustomPictureBox box = new CustomPictureBox(photo.GalleryID);

box.Image = Image.FromStream(response.GetResponseStream());

current++;

int percentage = (int)(((float)current / (float)photos.Length) * 100);

this.ImageListBackgroundWorker2.ReportProgress(percentage, box as object);

 

}

}



Answer this question

Backgroundworker Problem

  • Modderman

    that IS the dowork method. And i dont think it really matters what it does, because it never activates (other than sticking on the first line). However, it processes some results from a webservice.
  • richrobin5

    which line exactly is it sticking on you say the first line, but then you say it produces some results from calling the Web Service in the second line...


  • Ndt

    The eventg handler has to be working, becuase the method STARTS, it just does not continue.   
  • Adam Wagman

    sorry, i sohuld have been more clear. The photos array is a result of a previous call to the webservice (before the dowork function is called)


  • Christopher_N

    unless your eventhandler isnt hooked up correctly


  • tlaedre

    anybody       
  • SeanBenjaminC

    try wrapping the whole thing in a try/catch to see if you are getting some unseen error. Its a long shot, but worth trying

    try
    {
    //code
    }
    catch( Exception ex ) { MessageBox.Show(ex.ToString()); }


    the thing is, its weird that just nothing is happening...


  • noobOOP

    Stephen,

    What is the DoWork method What does it do



  • Backgroundworker Problem