2 Replies - 1301 Views - Last Post: 21 June 2012 - 03:27 PM Rate Topic: -----

#1 jase81  Icon User is offline

  • D.I.C Head

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

Task: How to manage multiple WebClient requests

Posted 20 June 2012 - 06:10 PM

Hopefully someone can point me in the right direction:

I am making multiple WebClient requests to a bunch of different services and I want to wait until all the WebClient responses are received before I try to build my UI.

It works a bit like this, although no call is dependent on another's response except the GetMoreFieldInfo() method

Call 1: GetRecord() grabs the data
Call 2: GetDatabaseSchema() gets info about the table
Call 3: GetFieldSchema() gets info about the datatypes

GetFieldSchema also makes multiple requests to GetMoreFieldInfo(datatype) depending on the datatype

That means I don't know exactly how many services will be called.

Is there a way I can use locks or managed threads or maybe some other events to create my UI once all WebClients have finished?

Is This A Good Question/Topic? 0
  • +

Replies To: Task: How to manage multiple WebClient requests

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

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

Re: Task: How to manage multiple WebClient requests

Posted 21 June 2012 - 05:05 AM

If you are using .Net 4, you can use the Task class from the parallel framework. There is a method called Task.WaitAll. You give it an array of Task objects, and it will wait until all of them are completed before moving on.
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: Task: How to manage multiple WebClient requests

Posted 21 June 2012 - 03:27 PM

I'm not using .NET 4 unfortunately.

I found this which looks helpful:
http://csharperimage...rkflows-in.html

And also found this... http://nuget.org/pac...Threading.Tasks

Could be good.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1