ExecuteRelationshipQueryCompleted not firing when busy

488
2
12-28-2011 09:05 AM
RiverTaig1
Occasional Contributor
I am calling queryTask.ExecuteRelationshipQueryAsync on a layer (States) and am able to get back in the  ExecuteRelationshipQueryCompleted event, the results I am expecting (e.g., for a given State, I can get the related Counties for that State).  Likewise if I call ExecuteRelationshipQuery to find, say, the senators for that state, I can get those. However, what I would like to do is get both the related counties and the related senators for a state when a state is picked by the user. Strangely, the ExecuteRelationshipQueryCompleted only fires for the counties but not for the senators. If I move the query for senators first, then it fires, but the query for the counties does not.

Here's the tree-view type structure that I want to build when a person selects a state (Oregon) from a drop-down list.

OREGON
--COUNTIES
------Lane
------Benton
------...(more counties)
--SENATORS
------Bob Smith
------Sally Jones

I'm not sure I understand what the problem is...why doesn't the ExecuteRelationshipQueryCompleted event fire when I call it a second time?  Is it busy or something and therefore ignores me?  Is there someway to wait for it to complete one query before executing another.
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
You can't use the same task to execute 2 concurrent queries.

You have either to use 2 different query tasks, or, as you suggested, to wait for the first one to complete before executing another.
0 Kudos
TroyProctor
New Contributor III
I'm getting the same error message when trying to run a QueryTask and two RelateQueryTasks at the same time. Sometimes it works and sometimes it doesn't.

How would I go about executing my two relate query tasks once my original QueryTask is finished. I'm pretty sure that is where the problem is stemming from.

I've got this setup in conjunction with using the Identify Task. I use the Identify Task to grab the parcel # of a parcel and then pass that parameter to my regular Query Task and Relate Query Tasks. Works sometimes.

Note: Whenever just doing a query on a parcel based on #, address or tax payer name the Querytask and two Relate Queries never error out. It's only when first using the Identify Task, so I'm not sure if the issue might be with the Identify Task somewhere too.

Thanks for any help!
0 Kudos