Where is the logic to check if the user has signed in? Here is a tutorial video for you:
How to Create Login Form in C# 2020 - YouTube[
^]
UPDATED
Impossible to tell when as we do not know when you are executing the code. I would lock the form as shown below:
private void Form1_Shown(object sender, EventArgs e)
{
}
Example:
1. Main form:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Shown(object sender, EventArgs e)
{
frmLogin objfrmLogin = new frmLogin();
objfrmLogin.ShowDialog();
}
2. login form:
public partial class frmLogin : Form
{
public frmLogin()
{
InitializeComponent();
}
private void frmLogin_Shown(object sender, EventArgs e)
{
_ = DummyCheckinLogic();
}
private async Task DummyCheckinLogic()
{
await Task.Delay(1000).ConfigureAwait(false);
}
}