What Process.Getcurrentprocess(). Kill(); does?

Asked

Viewed 54 times

-1

I’m making a program, in it I have to stop the execution of a screen with a condition. I found a way to do it here on the Internet, but I don’t want to just copy, I want to understand!

Follows the code:

public void PararExecucaoERetornarAoMenu()
        {
            var menu = new TelaMenu(repositorioPessoa);
            menu.Executar();
            Process.GetCurrentProcess().Kill();
        }

What is it for? In what situations use? There are other functions that do the same thing as him?

1 answer

0

Basically Voce takes the recurring process with Process.GetCurrentProcess() and kills the same with the Kill(), as if Voce opened the task manager and forced the completion of it in this case the recurring process would be menu.Executar();

  • I understood, so for my case it is not usual, because it kills the entire program and not only the execution of a class where it was put. How could I do this without killing the entire program process? I will use my example: I have the class Telacadatro and in it I have fields(name, sex, age, nationality), I want the

  • I’m not sure but Voce can try using the Close(); example in doc: https://docs.microsoft.com/pt-br/dotnet/api/system.diagnostics.process.close?view=netframework-4.8

  • I also saw something similar in https://stackoverflow.com/questions/3077961/how-to-delete--instance-of-a-class

Browser other questions tagged

You are not signed in. Login or sign up in order to post.