我正在尝试在ArcGIS for server mapserver上执行查询。运行返回少量记录的查询很好但是,如果我运行一个返回大量记录的查询,我收到此错误:
CLR无法从COM上下文0x10e1080转换为 COM上下文0x10e0f58持续60秒。拥有的线程 目的地上下文/公寓很可能要么做非 抽空等待或处理很长时间的运行操作 抽取Windows消息。这种情况一般都是消极的 性能影响甚至可能导致应用程序变为非 响应或内存使用随着时间的推移不断累积。至 避免这个问题,所有单线程单元(STA)线程都应该 使用抽取等待原语(如CoWaitForMultipleHandles)和 在长时间运行期间定期泵送消息。
这是我的C#代码:
private void RunQuery()
{
_attributeQueryGraphicsLayer.Graphics.Clear();
QueryTask queryTask = new QueryTask("http://10.1.2.103:6080/arcgis/rest/services/Calvert_City_Test/MapServer/2");
queryTask.ExecuteCompleted += GeneralQueryTask_ExecuteCompleted;
queryTask.Failed += GeneralQueryTask_Failed;
var dirty = DateTime.UtcNow;
Query query = new Query();
query.OutFields.Add("*");
query.ReturnGeometry = true;
query.Where = "CIS_METR LIKE '%" + QueryParametersTextbox.Text + "%' OR COMMENTS LIKE '%" + QueryParametersTextbox.Text + "%'";
query.OutSpatialReference = MyMap.SpatialReference;
queryTask.ExecuteAsync(query);
}
// Draw results when query is complete
private void GeneralQueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
{
// Clear previous results
QueryDataGrid.Visibility = Visibility.Visible;
GraphicsLayer graphicsLayer = MyMap.Layers["QueryResults"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
// Check for new results
FeatureSet featureSet = args.FeatureSet;
if (featureSet.Features.Count > 0)
{
// Add results to map
foreach (Graphic resultFeature in featureSet.Features)
{
//resultFeature.Symbol = ResultsFillSymbol;
graphicsLayer.Graphics.Add(resultFeature);
}
}
else
{
MessageBox.Show("No features found");
}
}
// Notify when query fails
private void GeneralQueryTask_Failed(object sender, TaskFailedEventArgs args)
{
MessageBox.Show("Query failed: " + args.Error);
}
#endregion
注意:不能选择关闭此例外。它只会导致我的应用程序冻结。
任何帮助将不胜感激。如果您需要更多信息,请告诉我。