Reputation: 776
Given the projects like:
both projects (.Net Core 2.0) are run at startup:
I am trying to kill only KillingTest app without killing project KillingTestOtherApp, but when I am running code below, both console apps are closed.
KillingTest Program.cs
using System;
using System.Diagnostics;
namespace KillingTest
{
class Program
{
static void Main(string[] args)
{
var processId = Process.GetCurrentProcess().Id;
var process = Process.GetProcessById(processId);
process.Kill();
}
}
}
KillingTestOtherApp Program.cs
using System;
using System.Diagnostics;
namespace KillingTestOtherApp
{
class Program
{
static void Main(string[] args)
{
while (true)
{
Console.WriteLine(Process.GetCurrentProcess().Id);
System.Threading.Thread.Sleep(100);
}
}
}
}
What am I doing wrong?
[EDIT]
I opened the issue on .Netcore github:
github.com/dotnet/core/issues/1005
it is known bug in debugging process in Visual Studio when using .NET Core,
at present without solution (assuming we want to be able to debug all apps).
Upvotes: 2
Views: 303
Reputation: 299
I think your problem comes from the fact you are letting Visual Studio debug both programs. Because of this, when the first app commits Seppuku, Visual Studio is terminating the second program. When I told the second to 'Start without debugging', it continued to run after the first had been terminated.
Upvotes: 3