I’m trying to figure out how can I make sure that the event has fired before letting the rest of the code run.
I hook up an event like this:
public stati
The main problem was that executing a query is not semantically related to a service layer getting initialized and so it didn't make sense to put the query in the layer initialization event's listener method. Putting query code in an event handler method that runs when a map layer is initialized isn't logical.
I haven't yet started on examining the .NET 4.5 Task Parrallel library in any serious depth, so I've decided to do this.
In the event handling listener method, I made a call to the query method like this.
private void DynamicMapServiceLayer_Initialized(object sender, System.EventArgs evArgs)
{
QueryUrlParameters();
}
And then I keep the parameter querying procedure in a method that has a name that matches its responsibility:
public static void QueryUrlParameters()
{
Query query = GetParameterQuery();
QueryTask queryTask = new QueryTask(GetRestURL(dynMapServLayer));
queryTask.ExecuteCompleted += GraphicQueryTask_ExecuteCompleted;
queryTask.Failed += QueryTask_Failed;
queryTask.ExecuteAsync(query);
}
This is still not such a great solution.
I would have preferred a more elegant way of waiting for the event to have initialized; but it looks like this is all I've got for now.