-1

I'm trying to make a log in which has two validation methods to check who logged in. Now I have a problem where I need to call two methods at the same time. The code for now is like this, any help is appreciated.

    public void Log()
    {
        Login loginAccount = new Login();

        Console.WriteLine("Enter username: \n");
        loginAccount.Username = Console.ReadLine();

        Console.WriteLine("Enter password: \n");
        loginAccount.Password = Console.ReadLine();

        List<Login> UserLog = new List<Login>()
        {
           loginAccount
        };

        loginAccount.CheckUser(loginAccount.Username);
        loginAccount.CheckAdmin(loginAccount.Username);

    }
Toy99
  • 5
  • 5
  • 1
    Not sure why you need to call both methods at the same time, but you can use Parallel. - >https://stackoverflow.com/a/47937690/2315752 – Nekeniehl Jan 18 '19 at 10:07
  • Since I need to check the user type who logged in @Nekeniehl – Toy99 Jan 18 '19 at 10:10
  • 3
    That doesn't really mean you have to do it on parallel, you can check first the user and then the password. – Nekeniehl Jan 18 '19 at 10:11
  • also, you might want to do the checks before adding the user to the list of logged in users. That way you can just have the CheckUser and CheckAdmin return a boolean and then in an if-statement decide how to handle those. – Dennis Vanhout Jan 18 '19 at 10:16
  • Yes all of that is done, thanks anyways @DennisVanhout – Toy99 Jan 18 '19 at 10:18

1 Answers1

0

You may looking for something like this

    Task.Run(() => loginAccount.CheckUser(loginAccount.Username));
    Task.Run(() => loginAccount.CheckAdmin(loginAccount.Username));
konuralpt
  • 263
  • 2
  • 11