I have two exe(two console apps) named first.exe
and second.exe
, in which first
is invoking second
exe three times by using Process.start()
and passing different arguments.After these three execution finishes i want to run a method(only after finishing three methods).How to do that.
This is the way i am handling the three invokes in second.exe
static void Main(string[] args)
{
if (args[0] == "TC" && args[1] == "CS")
{
Processfiles("TCS");
}
if (args[0] == "RC" && args[1] == "CS")
{
Zipfiles("RCS");
}
if (args[0] == "CC" && args[1] == "CS")
{
Leveragefiles("CTS");
}
Downloadfiles();
}
Here my question is how to execute Downloadfiles();
method after the completion of three methods Processfiles("TCS");,Zipfiles("RCS");,Leveragefiles("CTS");
. Here the completion time of three methods vary at different times
Code used to start second.exe
is
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = System.Configuration.ConfigurationManager.AppSettings["PathExe"];
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dtr in ds.Tables["testG"].Rows)
{
startInfo.Arguments = dtr["TC_CODE"].ToString() + " " + dtr["CC_CODE"].ToString();
Process.Start(startInfo);
// System.Diagnostics.Process.Start(System.Configuration.ConfigurationManager.AppSettings["PathExe"], dtr["VENDOR_CODE"].ToString() + " " + dtr["TECH_CODE"].ToString());
}
}
}
catch (Exception ex)
{
mail.SendMail2(System.Configuration.ConfigurationManager.AppSettings["EmailFrom"], System.Configuration.ConfigurationManager.AppSettings["EmailCc"], null, ex.Message, "error", true);
log.Error(ex.Message);
}