static LaunchResult InnerLaunch(TryResolveTool tryResolveTool, string tempFile, string targetFile) { if (ShouldExitLaunch(tryResolveTool, targetFile, out var tool, out var result)) { DiffEngineTray.AddMove(tempFile, targetFile, null, null, false, null); return(result.Value); } tool.CommandAndArguments(tempFile, targetFile, out var arguments, out var command); if (ProcessCleanup.TryGetProcessInfo(command, out var processCommand)) { if (tool.AutoRefresh) { DiffEngineTray.AddMove(tempFile, targetFile, tool.ExePath, arguments, tool.IsMdi !, processCommand.Process); return(LaunchResult.AlreadyRunningAndSupportsRefresh); } KillIfMdi(tool, command); } if (MaxInstance.Reached()) { DiffEngineTray.AddMove(tempFile, targetFile, tool.ExePath, arguments, tool.IsMdi !, null); return(LaunchResult.TooManyRunningDiffTools); } var processId = LaunchProcess(tool, arguments); DiffEngineTray.AddMove(tempFile, targetFile, tool.ExePath, arguments, !tool.IsMdi, processId); return(LaunchResult.StartedNewInstance); }
public static async Task Write(Settings settings) { TargetPosition.SetTargetOnLeft(settings.TargetOnLeft); MaxInstance.SetForUser(settings.MaxInstancesToLaunch); File.Delete(FilePath); await using var stream = File.OpenWrite(FilePath); await JsonSerializer.SerializeAsync(stream, settings); }
public static void MaxInstancesToLaunch(int value) { Guard.AgainstNegativeAndZero(value, nameof(value)); MaxInstance.Set(value); }
public static void MaxInstancesToLaunch(int value) => MaxInstance.SetForAppDomain(value);