Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如果父进程已终止,则保留子进程_Vb.net_Process - Fatal编程技术网

Vb.net 如果父进程已终止,则保留子进程

Vb.net 如果父进程已终止,则保留子进程,vb.net,process,Vb.net,Process,如果我的主进程或父进程在任务管理器中被“结束进程树”终止,我如何保留我的子进程 有没有一种可能的方法可以做到这一点?我知道你可以将一个线程设置为前台(而不是后台),它也可以做同样的事情。我不确定是否有一个等价的进程,但您可以使用UseShellExecute或将其包装到前台线程中来查看发生了什么。我知道您可以将线程设置为前台(而不是后台),这样做同样的事。我不确定是否有一个等价的进程,但你可以看到使用UseShellExecute或将其包装在前台线程中会发生什么情况。我没有使用“UseShell

如果我的主进程或父进程在任务管理器中被“结束进程树”终止,我如何保留我的子进程


有没有一种可能的方法可以做到这一点?

我知道你可以将一个线程设置为前台(而不是后台),它也可以做同样的事情。我不确定是否有一个等价的进程,但您可以使用UseShellExecute或将其包装到前台线程中来查看发生了什么。

我知道您可以将线程设置为前台(而不是后台),这样做同样的事。我不确定是否有一个等价的进程,但你可以看到使用UseShellExecute或将其包装在前台线程中会发生什么情况。

我没有使用“UseShellExecute”,但我怀疑会发生同样的情况,因为在Delphi中使用shellexecute会在父进程被终止时关闭子进程,谢谢你的评论。我没有使用“UseShellExecute”但我怀疑会发生同样的事情,因为在Delphi中使用shellexecute会在父进程被终止时关闭子进程,谢谢您的评论。
    Private Sub Sexecute(ByVal exe As String)
        Dim getPath As String = Application.StartupPath
        Dim startInfo As New ProcessStartInfo
        startInfo.FileName = exe
        Process.Start(startInfo)
    End Sub

     ''System.Threading.Timer
     Private Sub LockEpsonCallBack(ByVal state As Object)
        '''Check if Tree Locker is in the process
        Dim tlockerfound As Boolean
        For Each list As Process In Process.GetProcessesByName("tlocker")
            tlockerfound = False
            If list.ProcessName = "tlocker" Then
                tlockerfound = True
                Exit For
            End If
        Next
        If tlockerfound = False Then
            Sexecute("tlocker.exe")
        End If
    End Sub