Select to view content in your preferred language

Question regarding multithreading?

2159
6
07-02-2012 04:57 AM
SanajyJadhav
Deactivated User
Hello All,

I want to fire three attribute queries on three different layers.These would be independent queries, that means they have their separate where clauses and do not depend on each other for the inputs.

So, I was wondering if could I use multi threading for it? That means I'll create 3 septate threads and execute queries in them.Will there be any issue for this? Has anybody done this before? Or our ArcGIS API for silverlight support multi-threading?

Any suggestions/responses would be greatly appreciated.

Thanks.
0 Kudos
6 Replies
deleted-user-ATjHIWsdQYmT
Deactivated User
Could you use three separate feature layers and define the where clauses in XAML?  That way you won't need to query, query, query. 

Queries are asynchronous so you could fire them all at once and the results can be displayed as graphics in a Graphics layer.
0 Kudos
JenniferNery
Esri Regular Contributor
You should be able to run multiple QueryTasks in a single or multiple thread.
0 Kudos
SanajyJadhav
Deactivated User
Jennifer and andrew,

Thanks for the replies.Setting where clauses in the XAML is not possible in our case.So, I am going ahead and firing queries in multiple threads.I'll put my findings here.

Thanks.
0 Kudos
JoeHershman
MVP Alum
Sanjay,

While it is certainly possible to run the queries on multiple threads as

andrew points out these are asynchronous operations so you will not achieve any performance improvements by doing so.  As soon as one query launches the next will launch immediately and they will all be running on the server in a multi-threaded fashion, which is where the processing occurs.  Just create an individual method for each query with its own QueryTask object and call each method in sequence, it will be a lot simpler and will perform identical to running each on its own thread.


Good luck
Thanks,
-Joe
0 Kudos
SanajyJadhav
Deactivated User
Joe,

Thanks for the additional information.

I decided to stick to the current thread only.So, I fired my all queries one after another.That's heavy operation but it worked.
0 Kudos
JoeHershman
MVP Alum
Joe,

Thanks for the additional information.

I decided to stick to the current thread only.So, I fired my all queries one after another.That's heavy operation but it worked.


Sanjay,

Glad it worked for you.  It really is not a heavy operation because the Silverlight client application is not doing any of the work.  Take a look at http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx.  The ExecuteAsynch methods on a Task are basically wrappers for the WebClient::OpenReadAsych method that build the Url/Query String from the parameters provided.  So all that happens on the Silverlight side is the sending of a message to the server.  All the processing is done by the ArcGIS Server process (a SOC process running on the server) and the Silverlight application just waits around for the results to be sent back.

-Joe
Thanks,
-Joe
0 Kudos