I have a following situation
kl.KeyDown += CheckPwd;
while(flag)
System.Windows.Forms.Application.DoEvents();
//continue other code based on "Success"
//This will be called for every keydown
void CheckPwd(object sender, KeyEventArgs e)
{
//some code here
if(....)
{
flag = true;
Success = true;
kl.KeyDown -= CheckPwd;
}
else
{
flag = true;
Success = false;
kl.KeyDown -= CheckPwd;
}
}
Here I want to avoid using Application.DoEvents()
. I tried using ManualResetEvent
, but when I call WaitOne()
it is blocking current thread, and causing this, CheckPwd
is not firing up. How can I achieve this?