[KOE-14] Restarter now waits for the Outlook process to finish before starting a new one.

This commit is contained in:
Patrick Simpson 2017-03-01 11:28:57 +01:00
parent c0170bf856
commit 8746702052
2 changed files with 29 additions and 4 deletions

View File

@ -150,7 +150,7 @@ namespace Acacia.Stubs.OutlookWrappers
// Run that // Run that
Process process = new Process(); Process process = new Process();
process.StartInfo = new ProcessStartInfo(path, Environment.CommandLine); process.StartInfo = new ProcessStartInfo(path, Process.GetCurrentProcess().Id + " " + Environment.CommandLine);
process.Start(); process.Start();
// And close us and any other windows // And close us and any other windows

View File

@ -17,20 +17,45 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace OutlookRestarter namespace OutlookRestarter
{ {
class Program class Program
{ {
/// <summary>
/// Entry point.
/// Arguments:
/// 0 - parent pid
/// 1 - parent path
/// 2 - arguments
/// n - ...
/// </summary>
/// <param name="args"></param>
[STAThread] [STAThread]
static void Main(string[] args) static void Main(string[] args)
{ {
Process process = new Process(); string procPath = args[1];
process.StartInfo = new ProcessStartInfo(args[0], string.Join(" ", args.Skip(1))); var procArgs = args.Skip(2);
process.Start(); try
{
// Attempt waiting for the process to finish
int procId = int.Parse(args[0]);
Process proc = Process.GetProcessById(procId);
proc.WaitForExit(15000);
}
finally
{
// Start the process
Process process = new Process();
process.StartInfo = new ProcessStartInfo(procPath, string.Join(" ", procArgs));
process.Start();
}
} }
} }
} }