首页 \ 问答 \ 启动长时间运行后台进程并检查状态(Start long running background process and check the status)

启动长时间运行后台进程并检查状态(Start long running background process and check the status)

我想从Delphi开始一个可能长时间运行的后台进程。 我想让流程独立运行,但首先我想检查流程是否正常运行。

如果在启动时出现任何问题,我想捕获写入standardErr的任何输出并记录它。 如果后台进程启动正常,我的程序需要能够退出并使生成的进程继续运行。

psuedo代码将是这样的:

process:=RunProgramInBackground('someCommand.exe');
sleep(1000); // Wait a bit to see if the program started OK
if process.Finished and process.ExitCode=FAIL then 
    Raise Exception.Create(process.ErrorStream);
process.Dispose; // Close any connection we may still have to the running process
Program.Exit; // Background process keeps running

我已经看了几件事(WinExec,CreateProcess,ShellExecute,JclMiscel),但找不到我正在尝试做的任何示例。 做这个的最好方式是什么?

我正在使用Delphi 2010

后台进程是我没有源代码的第三方程序。


I want to start a potentially long running background process from Delphi. I want to leave the process running independently, but first I want to check that the process started OK.

If anything went wrong on startup, I want to capture any output written to standardErr and log it. If the background process starts OK, my program needs to be able to exit and leave the spawned process running.

The psuedo code would be something like this:

process:=RunProgramInBackground('someCommand.exe');
sleep(1000); // Wait a bit to see if the program started OK
if process.Finished and process.ExitCode=FAIL then 
    Raise Exception.Create(process.ErrorStream);
process.Dispose; // Close any connection we may still have to the running process
Program.Exit; // Background process keeps running

I've looked at a few things (WinExec, CreateProcess, ShellExecute, JclMiscel) but can't find any examples for what I'm trying to do. What is the best way to do this?

I'm using Delphi 2010

The background process is a 3rd party program I don't have the source to.


原文:https://stackoverflow.com/questions/7102514
更新时间:2023-06-09 09:06

最满意答案

我终于发现了什么问题,我不知道原因,但就是这样。

删除此行

itemText.setEditable(false);

TextArea捕获事件。

我没有找到在诺基亚SDK 2.0中这个代码工作的原因以及为什么不在这里。 安德有另一个事实。 我将TextArea设置为可编辑,并且它不可编辑o_O


I've finally found what is the problem, I don't know the reason why but that's it.

Removing this line

itemText.setEditable(false);

the TextArea catches the events.

I don't find the reason that in Nokia SDK 2.0 this code is working and why here is not. Ande there is another fact. I set the TextAreato editable, and it is not editable o_O

相关问答

更多
  • 尝试这个: try { // Need to explicitly cast the child to TextField otherwise // we are making an implicit cast and will get an error. var textField:TextField = child as TextField; var txtanim:TextAnim = new TextAnim( textField); } catch (err ...
  • 将文本字段声明为全局。在alertView的方法中单击- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex只需要获取文本字段的值并执行所需的操作。 。 修改后的代码 UITextField *myTextField; ... { UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedStrin ...
  • TextBox应该触发ChangeEvent (或ValueChangeEvent - 目前不知道)。 所以你可以在构造函数中轻松地做这样的事情: this.addChangeHandler(new ChangeHandler ... 如果这还不够,您还可以收听Focus事件。 Thanks for your help. I figured it out by myself today and it is quiet simple. I didn't notice, that there is alrea ...
  • ComboBox有一个setCellFactory方法,允许您创建自己的自定义ComboBox。 看一下这个例子: Custom Cell Factory 。 ComboBox has a setCellFactory method that allows you to create your own custom ComboBox. Take a look at this example: Custom Cell Factory.
  • stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownListener); function keyDownListener(event:KeyboardEvent):void { if(event.keyCode == Keyboard.ENTER) { square_mc.width = square_mc.height = int(side_txt.text()); } } stage.addEventListener(Key ...
  • 我终于发现了什么问题,我不知道原因,但就是这样。 删除此行 itemText.setEditable(false); TextArea捕获事件。 我没有找到在诺基亚SDK 2.0中这个代码工作的原因以及为什么不在这里。 安德有另一个事实。 我将TextArea设置为可编辑,并且它不可编辑o_O I've finally found what is the problem, I don't know the reason why but that's it. Removing this line itemT ...
  • 我不确定到底要做什么,但是当我们按下回车键时,我找到了一种获取TextField的方法。 在TextFieldCell类中,我添加了一个setOnAction来获取TextField用户输入的内容。 TextField textField = new TextField(input.get(count)); textField.setUserData(enumElement); textField.setOnAction(event -> { System.out.println("Gotcha"); ...
  • 例如,有几种方便的方法可以做到这一点 weightTF.setOnKeyPressed(new EventHandler() { @Override public void handle(KeyEvent event) { // do stuff } }); 只要在TextField中按下某个键,就会执行此操作。 您可能想要检查按下的键是否是特定键。 这可以通过以下方式实现 if(event.getCode() == KeyCode.TAB){ ...
  • 您需要在init方法中调用this._super()来维护视图的默认行为: ... init: function() { this._super(); } ... 希望能帮助到你。 You need to call this._super() inside your init method to maintain the view's default behaviour: ... init: function() { this._super(); } ... Hope it helps.

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。