944,092 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1820
  • VB.NET RSS
Nov 30th, 2007
0

Problem running multiple external apps

Expand Post »
Hi,

I have a class that runs an external ap using shell then waits till the app is quit before carrying on.

Does anybody know if it is possible to start an app say by clicking a button then be told when the app has closed. The app can be open more than once.

The problem I have is when the code is run everything stops till the app has finished.

Hope this makes sense.

Here is the code I have so far:

VB.NET Syntax (Toggle Plain Text)
  1. Public Function StartAndWait(ByVal ProcessPath As String, ByVal Licence As Integer)
  2. Dim startProcess As System.Diagnostics.Process
  3. Try
  4. startProcess = New System.Diagnostics.Process()
  5. startProcess.StartInfo.FileName = ProcessPath
  6. startProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
  7. startProcess.Start()
  8.  
  9. 'Wait until the process passes back an exit code
  10. startProcess.WaitForExit()
  11.  
  12. ' Check Exit code to see if process finished without error.
  13. If startProcess.ExitCode <> 0 Then
  14. MessageBox.Show("Exit Code: " & startProcess.ExitCode)
  15. End If
  16.  
  17. 'Free resources associated with this process
  18. startProcess.Close()
  19.  
  20. StartAndWait = True
  21.  
  22. Catch
  23. StartAndWait = False
  24. MessageBox.Show("Could not start process " & ProcessPath, "Error")
  25. End Try
  26. End Function
Reputation Points: 24
Solved Threads: 6
Junior Poster in Training
purplegerbil is offline Offline
78 posts
since Apr 2005
Dec 1st, 2007
0

Re: Problem running multiple external apps

I would try using Multi-Threading

Make the main thread continue running your application and the NEW Multi-Thread the open the other application

when the application is running the new thread will pause but your main app will continue to run also when the external app is closed the new thread will continue (add a msgbox in the new thread) and then the thread will close



Multi-Threading
http://www.taylorsnet.co.uk/SourceCo...px?SourceID=20
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Dec 1st, 2007
0

Re: Problem running multiple external apps

Thanks for your reply. I will give it a go on Monday (work). I'm new to VB.NEt. In the process of moving from VB6.

The link you added looks great as well.

Cheers,
PG
Reputation Points: 24
Solved Threads: 6
Junior Poster in Training
purplegerbil is offline Offline
78 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: How To alleviate two different date
Next Thread in VB.NET Forum Timeline: Help with buttons at runtime





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC