Skip to content

Instantly share code, notes, and snippets.

@vendettamit
Created January 28, 2016 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vendettamit/1470b06c950ab0bd4dde to your computer and use it in GitHub Desktop.
Save vendettamit/1470b06c950ab0bd4dde to your computer and use it in GitHub Desktop.
internal class ProcessInvoker
{
/// <summary>
/// Invokes the host process for test service
/// </summary>
public static void InvokeDummyService()
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
ProcessStartInfo info = new ProcessStartInfo(Path.Combine(path, "DummyService.exe"));
info.UseShellExecute = true;
info.WorkingDirectory = path;
var process = Process.Start(info);
// This is what would attach the process to current VS debugger
AttachDebugger.ToProcess(process.Id);
}
/// <summary>
/// Kills the process of service host
/// </summary>
public static void KillDummyService()
{
Process.GetProcessesByName("DummyService").ToList().ForEach(x => x.Kill());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment