GP学习(四)—Running a geoprocessing tool using background geoprocessing
Running a geoprocessing tool using background geoprocessing |
这句话的意思应该是单独设置线程跑GP tool而不影响前台程序的用户交互。
In this topic
- Geoprocessing
- Background geoprocessing
- Submitting a tool
- Checking tool execution status
- Geoprocessor events
- ToolExecuting event
- ProgressChanged event
- ToolExecuted event
- IGeoProcessorResult
- Canceling a tool
- Layer and data usage during tool execution
- Edit sessions and background geoprocessing
- Start editing then execute in the background
- Execute in the background then start editing
Geoprocessing
Background geoprocessing
- Submitting the tool for execution.
- Checking the tool's execution status.
Submitting a tool
[C#]
ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.GeoProcessor(); gp.OverwriteOutput = true; //Register to receive the geoprocessor event when the tools have completed execution. gp.ToolExecuted += new EventHandler < ESRI.ArcGIS.Geoprocessor.ToolExecutedEventArgs> (gpToolExecuted); IGeoProcessorResult2 gpResult = gp.ExecuteAsync("CopyFeatures", parameters)asIGeoProcessorResult2;
- Chaining the tools within a geoprocessing model, which can be run as described in Consuming a geoprocessing model tool in .NET. A model is treated as a single tool and the existence of any intermediate data will not be validated by the geoprocessor.
- Maintaining your geoprocessing queue as shown in Executing geoprocessing tools in the background.
Checking tool execution status
- Register and listen for the Geoprocessor.ToolExecuted events and, optionally, the other events (this is the most common option).
- Periodically query IGeoprocessorResult.
Geoprocessor events
- The ToolExecuting event is fired by all tools before a tool is taken from the geoprocessing queue and executed in the background. At this time, the tool's IGeoProcessorResult.Status property is still esriJobStatus.esriJobWaiting.
- The MessagesCreated event and the ProgressChanged event can fire during tool execution. These events fire depending on which tool is executing and how much data the tool is processing.
- The ToolExecuted event is fired by all tools when background execution has stopped.
ToolExecuting event
[C#]
public void gpToolExecuting(object sender, ToolExecutingEventArgs e) {IGeoProcessorResult2 result = e.GPResult as IGeoProcessorResult2;//Determine if this is the tool to handle this event.if (result.Process.Tool.Name.Equals("CopyFeatures") && result.GetInput(0).GetAsText().Equals(@"c:\Europe_Roads\Europe_Roads") && result.GetOutput(0).GetAsText().Equals(@"c:\Europe_Roads\Europe_Roads_Copy")){//Application specific code.} }
ProgressChanged event
[C#]
public void gpProgressChanged(object sender, ProgressChangedEventArgs e) {System.Windows.Forms.ProgressBar progressBar = myProgressBar;IGeoProcessorResult2 gpResult = (IGeoProcessorResult2)e.GPResult;switch (e.ProgressChangedType){case (ProgressChangedType.Show): //The tool that is running reports progress or has stopped reporting progress; make the // progress bar visible if appropriate. progressBar.Visible = e.Show;break;case (ProgressChangedType.Message): //The application does not use these, since a tool being used reports percentage progress.break;case (ProgressChangedType.Percentage): progressBar.Value = (int)e.ProgressPercentage;break;default:throw new ApplicationException("unexpected ProgressChangedEventsArgs.ProgressChangedType");break;} }
ToolExecuted event
When a tool has executed, the return value, status of the job, and all messages can be retrieved. See the following code example:
[C#]
public void gpToolExecuted(object sender, ToolExecutedEventArgs e) {IGeoProcessorResult2 result = e.GPResult as IGeoProcessorResult2;if (result.Status.Equals(esriJobStatus.esriJobSucceeded)){//Check that there are no information or warning messages.if (result.MaxSeverity == 0){//Get the return value.object returnValue = result.ReturnValue;//Application specific code, //for example, find the layer to which this return value corresponds.}else{//Application specific code.}}else{//Get all messages.IGPMessages msgs = result.GetResultMessages();for (int i = 0; i < result.MessageCount; i++){IGPMessage2 msg = msgs.GetMessage(i)as IGPMessage2;//Application specific code.}} }
IGeoProcessorResult
Canceling a tool
Layer and data usage during tool execution
- Changing the visibility, select ability, and connection details of a layer input to or output from an executing geoprocessing tool.
- Searching and selecting data input to a geoprocessing tool, for example, using the IFeatureLayer.Search and IFeatureClass.Select methods.
- Editing table rows of input or output data in or out of an edit session.
- Using the IFeatureLayer.Search and IFeatureClass.Select methods on output data. The set of table rows returned is undefined, since the table is in the process of being populated.
Edit sessions and background geoprocessing
Start editing then execute in the background
[C#]
public void gpToolExecuting(object sender, ToolExecutingEventArgs e) {IGeoProcessorResult2 result = e.GPResult as IGeoProcessorResult2;//Get the single feature class input parameter.IGPParameter parameter = result.Process.InputParameters.get_Element(0)asIGPParameter;string parameterPath = "";if (parameter.DataType.DisplayName.Equals("FeatureClass")){parameterPath = parameter.Value.GetAsText();}//Check whether this dataset is being edited.ESRI.ArcGIS.Controls.EngineEditor engineEditor = newESRI.ArcGIS.Controls.EngineEditor();if (engineEditor.EditState == esriEngineEditState.esriEngineStateEditing &&engineEditor.EditWorkspace != null){IEnumDatasetName datasetNames = engineEditor.EditWorkspace.get_DatasetNames(esriDatasetType.esriDTAny);IDatasetName name = datasetNames.Next();while (name != null){string path = engineEditor.EditWorkspace.PathName + @"\" + name.Name;if (path.Equals(parameterPath)){//This datset is being edited. Prompt the user to stop editing.}}} }
Execute in the background then start editing
See Also:
How to run a geoprocessing tool
How to work with geoprocessing services
Geoprocessing
Using geoprocessing
To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
- ESRI.ArcGIS.Geoprocessing
- ESRI.ArcGIS.Geoprocessor
- ESRI.ArcGIS.Geodatabase
Development licensing | Deployment licensing |
---|---|
Engine Developer Kit | Engine Runtime |
ArcView | ArcView |
ArcEditor | ArcEditor |
ArcInfo | ArcInfo |
GP学习(四)—Running a geoprocessing tool using background geoprocessing相关推荐
- GP学习(三)—How to run a geoprocessing tool
声明:仅做自己学习整理用,内容拷贝自ArcEngine SDK开发文档 How to run a geoprocessing tool In this topic Running a geoproce ...
- GP学习整理(一)—Geoprocessing assembly and Geoprocessor managed assembly
声明:仅做自己学习整理用,内容拷贝自ArcEngine SDK开发文档 Geoprocessing assembly overview In this topic About the Geoproce ...
- GP学习(二)—Executing tools and Accesubg licensing0
声明:仅做自己学习整理用,内容拷贝自ArcEngine SDK开发文档 Executing tools In this topic About roadmap to executing tools C ...
- GP学习(五)—ArcGIS Toolbox Reference dialog box
声明:仅做自己学习整理用,内容拷贝自ArcEngine SDK开发文档 ArcGIS Toolbox Reference dialog box Summary The ArcGIS Toolbox R ...
- RTKLIB专题学习(四)---单点定位实现初识(二)
RTKLIB专题学习(四)-单点定位实现初识(二) 今天我们来继续学习RTKLIB中单点定位的调用情况,上一篇在这里:RTKLIB专题学习(四)-单点定位实现初识(一) 1.上篇说到了调用procpo ...
- 鸿蒙Hi3861学习十九-DevEco Device Tool源码获取、编译、下载
一.简介 在上一篇文章中,已经讲述了如何在Windows通过Remote SSH远程连接Linux下的DevEco Device Tool.这篇文章,来说一下关于源码的获取.编译与下载.建议先按照上一 ...
- C#多线程学习(四) 多线程的自动管理(线程池) (转载系列)——继续搜索引擎研究...
在多线程的程序中,经常会出现两种情况: 一种情况: 应用程序中,线程把大部分的时间花费在等待状态,等待某个事件发生,然后才能给予响应 这一般使用ThreadPo ...
- python学习四(处理数据)
python学习四(处理数据) head first python中的一个数据处理的例子 有四个U10选手的600米成绩,请取出每个选手跑的最快的3个时间.以下是四位选手的9次成绩 James 2-3 ...
- PyTorch框架学习四——计算图与动态图机制
PyTorch框架学习四--计算图与动态图机制 一.计算图 二.动态图与静态图 三.torch.autograd 1.torch.autograd.backward() 2.torch.autogra ...
最新文章
- clear arp-cache作用_肇庆Sylvin-2900-75-Clear
- hide handkerchief(hdu2104)
- JS判断是否出现滚动条
- 他言行不一屡次跳槽,还升职加薪走上了人生巅峰,全数学界都炸了......
- html5爱情树怎么修改,jQuery结合HTML5制作的爱心树表白动画
- fafu oj 1266 数数
- 【转】HTTP协议之multipart/form-data请求分析
- codeigniter中 get_instance()的应用
- java JDBC入门及案例演示
- 网管必读-常用网络命令
- 什么软件可以测试QQ特别关心,qq特别关心查询工具
- 思科CISCO常用命令汇总
- 计算机cmd管理员,cmd获取管理员权限的命令是什么
- (三)空域图像增强:像素联系和模板运算
- html圈小猫小游戏
- 易支付源码 28k支付第四方支付源码-Oreo支付系统
- 【论文笔记】Switching Convolutional Neural Network for Crowd Counting
- android 六边形简书,水波浪贝塞尔效果(六边形)
- 基于Spring boot框架开发的电商网站系统
- rust大油田分解机_睡梦中,狂风起!大棚棉被刮翻了,卷帘机也连带吹坏了......
热门文章
- bzoj3533 [Sdoi2014]向量集 可持久化凸包+二分
- 2017.9.20 回文串 思考记录
- 2017.9.17 相关分析 思考记录
- 2017.6.4 problem b 失败总结
- 每日小记2017.2.22
- bes2300 tws配对_tws 耳机春天来了!
- linux中Cron定时任务系统命令详解
- java final修改器_Java中的“ final”关键字如何工作?(我仍然可以修改对象。)...
- tensorflow2.0 图像处理项目_游戏爱好者应该看看这个开源项目
- python 将数据写入csv文件