3 Replies - 11370 Views - Last Post: 07 June 2012 - 06:23 AM

#1 jase81  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Problem: How to build a control AFTER you get a WebClient response

Posted 04 June 2012 - 08:26 PM

I have a map.
On that map are features.
When the user clicks somewhere on the map the asynchronous WebClient goes off and grabs a list of features that are present at that point.
Then a context menu pops up giving the user the option to select which feature they wanted.

Problem: The WebClient call doesn't wait to finish before the context menu builds its list of items. Because the WebClient doesn't have the items, the context menu fails.

How do I make this work? From what I've read, using a wait handler on the UI thread is a no-no. What else can I do?

Code looks a bit like this:

// create gesture handlers
// catch gesture
// use webclient to call the web service
// download complete handler processes result

THEN

// build the context menu with the appropriate options

If anyone has any ideas about where I could change my process or tutorials or methods I could look at it would be great.

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Problem: How to build a control AFTER you get a WebClient response

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Problem: How to build a control AFTER you get a WebClient response

Posted 06 June 2012 - 09:05 AM

Where is your code?

If the WebClient does an async call, then there will be a Completed event for that call. Your context menu generation code would go in that Completed event handler.
Was This Post Helpful? 0
  • +
  • -

#3 jase81  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Re: Problem: How to build a control AFTER you get a WebClient response

Posted 06 June 2012 - 05:38 PM

I just realised the problem is that I am sharing the WebClient and the DownloadComplete handler. If I create separate WebClients and handlers for each request I shouldn't run into that problem.

That is assuming that the WebClient responses will come back in the order they are sent? Any idea on that one?
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Problem: How to build a control AFTER you get a WebClient response

Posted 07 June 2012 - 06:23 AM

View Postjase81, on 06 June 2012 - 08:38 PM, said:

That is assuming that the WebClient responses will come back in the order they are sent? Any idea on that one?


No, they are not guaranteed to come back in the order they are called. If the first call takes 5 seconds to complete, and the second call takes 2 seconds to complete, the second will return before the first.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1