0

How can I have my main application open a separate application and have it call an event in the main application when the separate application closes?

At the moment I am using:

Process.Start("notepad.exe", "C:\test.txt");

What I attempt to achieve is to get the main application to re-read the contents of test.txt once the separate application has saved and closed.

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
Jimmay
  • 959
  • 3
  • 13
  • 27

1 Answers1

1
Dim Process As Process = new Process()
Process.StartInfo = new ProcessStartInfo("notepad", "C:\test.txt")
Process.Start()
Process.WaitForExit()
// Do something
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
  • Thanks, but I don't want the main application to have to wait. I just want it to call an event once notepad closes. – Jimmay Dec 15 '13 at 12:31
  • What was the purpose of the @? – Jimmay Dec 15 '13 at 12:40
  • @Jimmay You noticed that before I rolled it back huh? Sorry about that! It's a C# thing, which I thought would be the same in VB. It isn't: [How to do a verbatim string literal in VB.NET?](http://stackoverflow.com/q/13155449) – Danny Beckett Dec 15 '13 at 12:41
  • If you don't want to block the program you can use the Process.Exited event rather than using threads. – user1937198 Dec 15 '13 at 12:52
  • Lol, good spot @Jimmay! (In case you hadn't already noticed, C# and VB are basically identical, ignoring these little differences) – Danny Beckett Dec 15 '13 at 12:52