So im trying to operate threads with key events, I managed to make them start by hitting key E and R( two thread), but i can't stop them by realeasing keys, keyup event doesnt work for some reason... (after starting, stopping i would like to restart them when needed... so no timer...)
C# WINDOWS APPLICATION Code:(method I'm using)
private void Yawspeed_KeyDown(object sender, KeyEventArgs e)
{
Thread yawspeedRightThread = new Thread(new ThreadStart(YawspeedRightThread));
Thread yawspeedLeftThread = new Thread(new ThreadStart(YawspeedLeftThread));
if (e.KeyCode == Keys.E)
{
yawspeedRightThread.Start();
}
if (e.KeyCode == Keys.R)
{
yawspeedLeftThread.Start();
}
}
((Method would be something like that?:
private void Yawspeed_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.E)
{
yawspeedRightThread.Abort();
}
if (e.KeyCode == Keys.R)
{
yawspeedLeftThread.Abort();
}
}
(Ending...)
private void Yawspeed_Load(object sender, EventArgs e)
{
}
#region Thread Functions
/// <summary>
/// This thread will move your cursor
/// </summary>
public static void YawspeedRightThread()
{
while (true)
...(Rest of the code, thread itself, functions...)