Select to view content in your preferred language

Query Multiple Layers - How to tell which ExecuteCompleted is for which layer?

606
2
05-26-2010 11:51 AM
DavidLowther
Deactivated User
My application allows a user to make multiple layers "active." Drawing a rectangle on the map selects features from all active layers within the rectangle. I've got this happening based on the good examples online.

However, one issue I have run into is that the QueryEventArgs class does not let me know what layer the results came from - nor do I have any way (that I can tell) to know which UserState is associated with which completed QueryTask. I thought maybe the QueryTask.Token ended up being the QueryEventArgs.UserState, but alas, no such luck.

Any ideas on how to associate the results of a query to a layer?

Thanks in advance for your help.
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor
You can use the userstate parameter in the ExecuteAsync to pass in an object that identifies the layer, for instance the layer instance, Layer ID or index (...or all of them in an array or custom class/struct etc). This is what the e.UserState value will contain when the request returns.

This is very similar to how for instance the methods in System.Net.WebClient works.
0 Kudos
DavidLowther
Deactivated User
Thanks for the quick reply Morten. Don't know why I didn't think to look there. Thanks.
0 Kudos