1
0
mirror of https://github.com/Kopano-dev/kopano-ol-extension.git synced 2023-10-10 13:37:40 +02:00

[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
Process process = new Process();
process.StartInfo = new ProcessStartInfo(path, Environment.CommandLine);
process.StartInfo = new ProcessStartInfo(path, Process.GetCurrentProcess().Id + " " + Environment.CommandLine);
process.Start();
// And close us and any other windows

View File

@ -17,20 +17,45 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OutlookRestarter
{
class Program
{
/// <summary>
/// Entry point.
/// Arguments:
/// 0 - parent pid
/// 1 - parent path
/// 2 - arguments
/// n - ...
/// </summary>
/// <param name="args"></param>
[STAThread]
static void Main(string[] args)
{
Process process = new Process();
process.StartInfo = new ProcessStartInfo(args[0], string.Join(" ", args.Skip(1)));
process.Start();
string procPath = args[1];
var procArgs = args.Skip(2);
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();
}
}
}
}