2
In the code below, the desktop application has to log in to a system, but when the user/password is wrong, it gives me the error message, but after I give the OK it keeps running. I tried the environment.exit()
and application.exit()
but they didn’t work. Nothing happened.
How would you stop the application and start again? Or go back to where you left off?
public void ConsultarSistemaRJ(string codPrograma)
{
log.GravarLog("Sistema RJ", "");
r.Espera("SELECIONE A OP", 17, 16, 29 );
r.PutString("6", 17, 38);
r.PutString("29", 17, 41);
r.EnviaEnter();
r.PutString(matricula, 8, 58);
r.PutString(senha, 9, 58);
r.EnviaEnter();
**if (r.txTela.Contains("CEFSNP"))
{
login = false;
MessageBox.Show("Login inválido!");
return;
}
if (login == false)
{
Environment.Exit(0);
}**
r.Espera("PAS SIPAS", 11, 27, 35);
r.PutString("PAS", 4, 15);
r.EnviaEnter();
r.PutString("001", 5, 15);
r.EnviaEnter();
see help: https://answall.com/questions/205483/login-em-c-com-base-data
– Rovann Linhalis
the execution of
Application.Exit()
is not immediate, it just signals to the OS that the application will close and then closes (qq thing running after the line will run), if your form is the main application you can callClose()
to close the form and the application will close– JMSlasher