Hi, I am trying to implement a sequence of calls to Geometry service. I want to implements these calls as Tasks. I have the following extension method, public static Task<IList<Graphic>> SimplifyTask(this GeometryService gc, IList<Graphic> graphics)
{
TaskCompletionSource<IList<Graphic>> tcs = new TaskCompletionSource<IList<Graphic>>();
EventHandler<GraphicsEventArgs> SimplifyCompleted = delegate { };
EventHandler<TaskFailedEventArgs> Failed = delegate { };
SimplifyCompleted = (sender, e) =>
{
gc.SimplifyCompleted -= SimplifyCompleted;
gc.Failed -= Failed;
tcs.TrySetResult(e.Results);
};
Failed = (sender, e) =>
{
gc.SimplifyCompleted -= SimplifyCompleted;
gc.Failed -= Failed;
tcs.TrySetException(e.Error);
};
try
{
gc.SimplifyCompleted += SimplifyCompleted;
gc.Failed += Failed;
gc.SimplifyAsync(graphics);
}
catch (Exception ex)
{
tcs.TrySetException(ex);
gc.SimplifyCompleted -= SimplifyCompleted;
gc.Failed -= Failed;
}
return tcs.Task;
} that I am trying to use through this code:
geometryService = new GeometryService("http://arcgis/ArcGIS/rest/services/Geometry/GeometryServer");
Task<IList<Graphic>> task1 = geometryService.SimplifyTask(PstLayer.Graphics);
Task.WaitAll(task1);
IList<Graphic> simplifiedPstLayer = task1.Result;
When the code reaches "Task.WaitAll(task1);" line, I wait for ever; Having breakpoints inside SimplifyCompleted and Failed handlers, the execution never reaches this point... Is there any help, pointers somebody has to offer? Thanks, George J.
... View more