Select to view content in your preferred language

How can I find out when a python script ends when running from within VB.Net

1710
2
Jump to solution
11-19-2014 07:06 AM
DaleShearer
Frequent Contributor

Hi, thanks for looking at mu question.  I am running a python script from within a vb.net application in ArcMap.  The script is called and creates a database, currently I run the script, visually check to see that the database is created then I run the next part of the application.  What I want to do is to eliminate me having to check to see that the database is created, so that when the python script ends the next part of the process can continue on from code.

So is there someway I can halt the VB.net code from executing until the python script is done.  What happens is if I try this is that the code fires off the python script and the VB.net code continues on before the database is created.

Thanks for your time.  Dale,

0 Kudos
1 Solution

Accepted Solutions
PaulCrickard1
Deactivated User

you should be able to use process.WaitForExit or use the Process.Exited Event like:

Private Sub myProcess_Exited(ByVal sender As Object, _

   ByVal e As System.EventArgs) Handles myProcess.Exited

  eventHandled = True

  Console.WriteLine("Exit time: {0}" & vbCrLf & _

   "Exit code: {1}" & vbCrLf & "Elapsed time: {2}", _

  myProcess.ExitTime, myProcess.ExitCode, elapsedTime)

   End Sub

See:

Process.Exited Event (System.Diagnostics)

or

Process.WaitForExit Method (System.Diagnostics)

View solution in original post

0 Kudos
2 Replies
PaulCrickard1
Deactivated User

you should be able to use process.WaitForExit or use the Process.Exited Event like:

Private Sub myProcess_Exited(ByVal sender As Object, _

   ByVal e As System.EventArgs) Handles myProcess.Exited

  eventHandled = True

  Console.WriteLine("Exit time: {0}" & vbCrLf & _

   "Exit code: {1}" & vbCrLf & "Elapsed time: {2}", _

  myProcess.ExitTime, myProcess.ExitCode, elapsedTime)

   End Sub

See:

Process.Exited Event (System.Diagnostics)

or

Process.WaitForExit Method (System.Diagnostics)

0 Kudos
DaleShearer
Frequent Contributor

Thanks Paul, I do appreciate it.  Now I am past that, but back to a prior VB.net-Python issue.  I will posting it in a minute.  Dale,

0 Kudos