Question

I am starting an external application from Visual Basic to perform CPU and memory intensive computations. The code more or less looks like the following:

    gApp = New CANoe.ApplicationgApp = New CANoe.Application
    While gApp Is Nothing 'wait until CANoe started
        Threading.Thread.Sleep(100)
    End While
    gApp.Open(canoeConfigFile, False, False)
    gApp.Configuration.OfflineSetup.Source = dataFile
    gMeasurement.Start()
    While (gMeasurement.Running)
            Threading.Thread.Sleep(1000)
    End While
    gApp.Quit()

Would it be possible to encapsulate the above code into a process? I am ultematelly looking for something like:

    Dim canoeProcess As New Process
    canoeProcess.StartInfo.FileName = "C:\Program Files (x86)\Vector CANoe 8.1\Exec32\CANoe32.exe"
    canoeProcess.Start()
    gApp = canoeProcess.Application
    ...

    ' (the code continues as the above)

    ...

The reason why I want to encapusalte the application into the process is that (i) I want to run muliple instances of the executable with different dataFiles as jobs and (ii) in case the canoe software hangs or does something weird I'd like to be able to kill the process from the VB application.

Is it possible to achieve the reverse? I.e., giving gApp Application object (that is running) to get its Process ID?

Any comments?

Was it helpful?

Solution

I believe the answer is that it is not possible. I am requesting the resources through the Windows COM interface and encapsulating it into a process might be even impossible (maybe a process does not exist at all)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top