Monday, 2 September 2013

VB: Encapsulating an Application Object with a Process

VB: Encapsulating an Application Object with a Process

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?

No comments:

Post a Comment