暂停执行程序 [英] Pausing an execution of a program

查看:107
本文介绍了暂停执行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




任何人都可以帮我解决以下问题:

如果给定的文件是
在指定目录中创建(由另一个进程)?

任何想法都将受到高度赞赏。


谢谢!

解决方案

格雷格,


简短的回答,你不能,不是除非该程序通过

公开一种机制。大多数程序都不会这样做,因为这是一个简单的方法来执行程序执行的麻烦。


你想做什么? br />

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com

" greg" < gr ************ @ gmail.comwrote in message

news:11 ****************** ****@z28g2000prd.googlegr oups.com ...





任何人都可以帮助我以下问题:

如果在指定目录中创建(由另一个进程)给定文件

,我如何暂停程序的执行?


任何想法都将受到高度赞赏。


谢谢!


任何人都可以帮助我出现以下问题:


如何在给定文件创建(由另一个进程)创建给定文件之前暂停执行程序一个指定的目录?


任何想法都将受到高度赞赏。



为什么没有东西等到文件存在,然后调用

程序来获取它?

如果应用程序是命令行驱动的,你可以等待文件,然后

发送应用程序来处理它。


< blockquote> 6月12日下午5:22,Nicholas Paldino [.NET / C#MVP]"

< m ... @ spam.guard.caspershouse.comwrote:


Greg,


简短回答,你不能,除非程序通过
$ b公开一种机制$ b这样做。大多数程序都不会这样做,因为这是一个简单的方法来执行程序执行的麻烦。


你想做什么? br />



这是一般情况。从Main我开始一个过程,这个过程需要进行一些计算并输出一个文件。由于我需要

文件用于程序的其余部分,我使用的是Process.WaitForExit()。

但是,在Main中启动的进程可以自行重启,如果是

发生Main中其余代码的执行。这是不好的,因为

还没有输出文件。因此,我希望实现的是

使用会在创建文件之前暂停程序的东西 -

处理程序?


Hi,

Can anyone help me with the following issue:
How can I pause the execution of a program until a given file is
created (by another process) in a specified directory?

Any ideas would be highly appreciated.

Thanks!

解决方案

Greg,

Short answer, you can''t, not unless the program exposes a mechanism by
which to do so. Most programs won''t do this though, as it is an easy way to
mess with program execution.

What are you trying to do?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"greg" <gr************@gmail.comwrote in message
news:11**********************@z28g2000prd.googlegr oups.com...

Hi,

Can anyone help me with the following issue:
How can I pause the execution of a program until a given file is
created (by another process) in a specified directory?

Any ideas would be highly appreciated.

Thanks!


Can anyone help me with the following issue:

How can I pause the execution of a program until a given file is
created (by another process) in a specified directory?

Any ideas would be highly appreciated.


Why not have something wait until the file exists, THEN call the
program to go get it?

If the app is command line driven you can wait for the file, and then
send off the app to process it.


On Jun 12, 5:22 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:

Greg,

Short answer, you can''t, not unless the program exposes a mechanism by
which to do so. Most programs won''t do this though, as it is an easy way to
mess with program execution.

What are you trying to do?

Here is the general picture. From Main I am starting a process which
is supposed to do some calculations and ouput a file. Since I need the
file for the rest of the program, I am using Process.WaitForExit().
However, the process started in Main can restart itself and if that
happens the rest of the code in Main is executed. This is bad since
there is not outputted file yet. Thus, what I was hoping to achieve is
use something that will halt the program until a file is created - a
handler?


这篇关于暂停执行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆