blackgold9

blackgold9 blackgold9

Niner since 2004

Comments

  • Dan Fernandez - Demo of C# Express (pull images from Google)

    I'm trying to duplicate the demo's functionality, but i keep getting threading access errors on my dowork function. As far as i can tell, nothing is accessing the main thread, but it keeps claiming that i am.

    localhost.GalleryComponentDataSet myset=(localhost.GalleryComponentDataSet)e.Argument;

    // int progress = 0;

    // BackgroundWorker worker = sender as BackgroundWorker;

    // worker.ReportProgress(progress++);

    //Load images

    foreach (localhost.GalleryComponentDataSet.PicsRow row in myset.Pics)

    {

    try

    {

    error here-->>Stream ImageStream = new WebClient().OpenRead("http://localhost/newalpha/"+String.Format("ViewPhoto-{0}.aspx?Width=50",row.ID));

    Image img = Image.FromStream(ImageStream);

    //UrlAndImage.Add(System.Configuration.ConfigurationSettings.AppSettings["WebsitePath"] + String.Format("ViewPhoto-{0}.aspx", row.ID), img);

    UrlAndImage.Add("http://localhost/newalpha/"+ String.Format("ViewPhoto-{0}.aspx", row.ID), img);

    }

    catch

    { }

    finally

    {

    // worker.ReportProgress(progress++);

    }

    }

    //Send result back to Form

    e.Result = UrlAndImage;