CTRL-C not captured by app if started from JetBrains tools

I am currently evaluating the JetBrains Ultimate package for my company, and while trying to either Cover the application using dotCover or profiling it using dotMemory (haven't done dotTrace yet), CTRL-C is not captured by my application.

Many of the applications we do are console applications using either TopShelf, which handles CTRL-C internally to terminate, or taking over the Console.CancelKeyPress event, setting ConsoleCancelEventArgs.Cancel = true, for manually controlling the termination phase using a cancellation token like this:

var tokenSource = new CancellationTokenSource();
Console.CancelKeyPress += (sender, eventArgs) =>
{
tokenSource.Cancel();
eventArgs.Cancel = true;
};

Neither seems to work and I have to use the Kill button, which, in the case of running under dotCover, will not allow me to actually see the covered code during shutdown.

0

Please sign in to leave a comment.