I am developing a Windows Services project using visual studio 2019. I created my service and everything is ok, it is running, calling my tasks from time to time!
But when I end the process through the task manager, my service stops without calling the onStop () method.
If I go to the task manager -> services and stop my service there, it calls onStop () normally and does what it has to do..
I'm trying to develop a kind of "anti hacker" for an online game server. If I can finish my service this way without causing it to fall into the onStop () method, my anti hacker will not work!
Anyone can help me?
my method onStop:
protected override void OnStop()
{
try
{
ProcessStartInfo processStartInfo = new ProcessStartInfo("taskkill", "/F /T /IM androidapp")
{
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
UseShellExecute = false,
WorkingDirectory = System.AppDomain.CurrentDomain.BaseDirectory,
RedirectStandardOutput = true,
RedirectStandardError = true
};
Process.Start(processStartInfo);
}
catch { }
}