启动长时间运行后台进程并检查状态(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
最满意答案
我终于发现了什么问题,我不知道原因,但就是这样。
删除此行
itemText.setEditable(false);
TextArea
捕获事件。我没有找到在诺基亚SDK 2.0中这个代码工作的原因以及为什么不在这里。 安德有另一个事实。 我将
TextArea
设置为可编辑,并且它不可编辑o_OI'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
TextArea
to editable, and it is not editable o_O
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
尝试这个: 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与TextField(ComboBox with TextField)[2023-07-25]
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. -
听取文本事件(Listening for textfield events)[2022-04-03]
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 ... -
从TextField捕获事件(Catch events from a TextField)[2022-12-21]
我终于发现了什么问题,我不知道原因,但就是这样。 删除此行 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.