locked
webclient_DownloadStringCompleted runs twice RRS feed

  • Question

  • I have a bug that I can't figure out how or why it's happening. I have an asynchronous method call to my server side class, in form of a

     webclient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webclient_DownloadStringCompleted);
     webclient.DownloadStringAsync(new Uri(wUrl));

    The server side class performs its methods once and upon return my webclient_DownloadStringCompleted method runs. But when the method is done it is run once again straight away, and I cannot figure out why.

    I guess I should write my code so that a problem like this doesn't matter anyway, but it really annoys me that I don't know why it's happening.

    /d
     

    Monday, June 30, 2008 6:02 AM

Answers

  • Where you add event handler? Put breakPoint on webclient.DownloadStringCompleted += ..., may be this code runs twice, for example, if you put dynamicly element on ContentControl, it's Loaded event fires twice, so if you add event handler there it's also will fire twice

    Monday, June 30, 2008 7:05 AM

All replies

  • Where you add event handler? Put breakPoint on webclient.DownloadStringCompleted += ..., may be this code runs twice, for example, if you put dynamicly element on ContentControl, it's Loaded event fires twice, so if you add event handler there it's also will fire twice

    Monday, June 30, 2008 7:05 AM
  •  Yes! Of course! Thank you. :)

    Monday, June 30, 2008 7:29 AM