call another C# program

jassie

Well-known member
Joined
Nov 13, 2012
Messages
61
Programming Experience
1-3
I am having a C# 2010 windows application call another C# 2008 windows application with the following code:
String Process_Arguments = null;
eRPT_Process.StartInfo.UseShellExecute = false;
eRPT_Process.StartInfo.FileName = strConsoleAppLocation;
Process_Arguments = strEncryptedValue + " " + strWebServiceurl + " 1 try";
eRPT_Process.StartInfo.Arguments = Process_Arguments;
eRPT_Process.Start();
eRPT_Process.WaitForExit(1800);
Process_Arguments = null;

My question is the following line of code:
eRPT_Process.WaitForExit(1800);

If this program does not wait for the other program to finish executing, could this make the second program stay in memory for awhile?

Basically the first program calls the second program in a loop. Thus could a thread from the previous call to the second program be running at the same time that another call to the second program is running? If so, could these cause the second program to have a memory leak?
if so how would you solve this problem?
 
If you're running the app every 1.8 seconds and it takes longer than that to exit then yes, you will end up with multiple instances running. That is not an issue in and of itself, but if you keep going then you may end up with quite a few instances running at the same time. Whether or not that's an issue depends on what the app does. You might want to rethink that design though.
 
If this program does not wait for the other program to finish executing, could this make the second program stay in memory for awhile?
No. Your application has no connection to other app other that having started the process.
Thus could a thread from the previous call to the second program be running at the same time that another call to the second program is running?
Yes. Process.Start return immediately, thus you can create another process immediately without the first having exited.
If so, could these cause the second program to have a memory leak?
No.

Your application will have a memory leak if you don't dispose each Process instance when you're done with them.
 
Back
Top Bottom