如何创建一个比其父进程寿命更长的进程 [英] How to create a Process that outlives its parent

查看:18
本文介绍了如何创建一个比其父进程寿命更长的进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我开发的平台启动外部更新程序应用程序.我想启动这个更新程序的原因是因为我的配置实用程序处理平台的更新和许可证配置,它与将部署更新的文件夹中的其他程序集共享依赖项.因此,虽然我可以重命名配置实用程序并在部署更新时覆盖它,但我无法重命名或覆盖它所依赖的 DLL.因此,外部更新程序应用程序.

I'm trying to launch an external updater application for a platform that I've developed. The reason I'd like to launch this updater is because my configuration utility which handles updates and license configuration for the platform has shared dependencies with other assemblies in the folder where the update will be deployed. So, while I can rename the configuration utility and overwrite it when deploying the update, I can't rename or overwrite the DLLs it depends on. Hence, the external updater application.

我正在处理配置实用程序中的所有更新收集逻辑,然后尝试启动更新程序来处理实际的文件复制/覆盖操作.显然,由于文件使用问题,我需要在更新程序开始后立即退出配置实用程序.

I'm handling all of the update gathering logic in the configuration utility, then attempting to launch the updater to handle the actual file copy/overwrite operations. Obviously, because of the file in use issues, I need the configuration utility to exit right after the updater begins.

我遇到的问题是我使用标准 Process.Start 方法启动更新程序,一旦配置实用程序退出,更新程序进程也会被终止.

The problem I'm having is that I'm using the standard Process.Start method of launching the updater, and as soon as the configuration utility exits, the updater process gets killed too.

有什么方法可以创建一个比其父进程寿命更长的进程,或者启动一个可以在启动它的程序之外运行的外部应用程序?

Is there any way that I can create a Process that outlives its parent, or launch an external application that can run beyond the program that launched it?

显然,在我的更新程序应用程序中,我错误地计算了传递给它的命令行参数的数量.因此,更新程序将立即退出.我误解了这意味着启动器应用程序正在杀死子"进程,而事实上,它不是.

Apparently, in my updater application, I miscalculated the number of command line arguments which are passed to it. Because of this, the updater would exit immediately. I misinterpreted this to mean that the launcher application was killing the "child" process, when in fact, it wasn't.

以下答案是正确的.

推荐答案

您所看到的问题似乎有不同的原因,因为 Process 类不会终止任何使用 启动的进程Process.Start 当您的应用程序退出时.

It seems that the problem you are seeing has a different reason because the Process class will not kill any processes started using Process.Start when your application exits.

查看这个简单的示例程序,计算器将保持打开状态:

See this simple sample program, the calculator will stay open:

using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        Process.Start(@"C:windowssystem32calc.exe");
    }
}

这篇关于如何创建一个比其父进程寿命更长的进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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