Hi all, My program is to do spatial query on eight layers. Since spatial query task is asynchronous call, so these eight layers are not called in order (like layer1, 2, 3....), but in disorder(layer3, 7, 2, 4....). I put a counter(returnedSpatialQueryCount) in the QueryTask_ExecuteCompleted to count the times
private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
{
returnedSpatialQueryCount += 1; // Add the variable by 1.
MessageBox.Show("count= " + returnedSpatialQueryCount);
MessageBox.Show("layerid= " + args.UserState.ToString());
}
But I found sometimes, some layers are skipped. Giving an example, after messagebox showing "count=2" which means spatial query task is completed for two times, messagebox will show "count=5" or "count=8" or something like this, which results not all of the eight layers are executed spatial query task. I am guessing since spatial query is asynchronous process, maybe ExecuteAsync() is getting be called simultaneously for 2 or more layers? Does anyone run into the same problem before? Any suggestions? Thank you!