2

I have two programs running. Program1.exe and Program2.exe.

Program1 is written in C# .Net4.8 and is used to upload/download transaction from the web, check for updates and handle various other tasks that Program2 cannot.

Program2 is written in VB6. Yeah, VB6... It's set for a rewrite but we aren't at that stage yet due to it's complexities. It is more of a use interface application.

When Program1 checks for updates and determines if there is one available. When Program2 shuts down, Program1 need to prompt the users that there is an update available and attempt to install it.

My issue is, how do I determine that Program2 has shut down to immediately prompt the user before they shut down the computer. I was thinking that Program2 creates a flag file and I watch for it with a filewatcher or I can put up a timer that checks if Program2 is running. I'm assuming I'll have to put the timer on 1 second intervals to catch it correctly.

Which is more efficient or is there a better way to handle this?

Any suggestions would be greatly appreciated.

  • You are using a polling pattern with the file watcher. IPC is better, check this link out: https://www.codeproject.com/Articles/6945/VB-NET-VB6-and-C-Interprocess-communication-via-Wi – jtalics Aug 22 '22 at 17:33
  • How are the two programs launched? Does the user starts manually the one after the other, or the one program starts automatically the other in the background? – Theodor Zoulias Aug 22 '22 at 17:41
  • @TheodorZoulias Program2 starts and then calls Program1 to start. Program1 sits in the background minimized while they work in Program2. – SomeoneSpecial Aug 22 '22 at 17:45
  • What do you mean by "efficient"? Its not clear what problem you are trying to solve. Have you tried both methods? – StayOnTarget Aug 24 '22 at 11:39

1 Answers1

1

Consider looking at it from a different perspective.

When Program2 shuts down, you could have it launch Program1 with a command line argument that tells it to check for updates. If no updates are available, Program1 shuts down silently. Otherwise, it prompts to apply the update and does so if allowed to.

Of course, this means adding command line parameter support to Program 1 (unless patching is all that it does).

But this way, you could run the patcher both before and after Program2 runs.

Mike Hofer
  • 16,477
  • 11
  • 74
  • 110
  • Thank you Mike for the response! Only problem with this is that both programs are continuously running. Program1 is already running so Program2 can't call a 2nd instance of it, the code prevents that. This is why I was wanting to know what is the best way for Program1 to know that Program2 has exited. – SomeoneSpecial Aug 22 '22 at 19:03