Using Winform with C# .Net.
I have a small issue which I thought was easy. When I run a function continuously the UI locked up so I decided to put the function on a background thread which I though would free up the UI. I wanted to free the UI so I could change the value on the scroll bar.
I did this add a button to start the thread I believe in the background
private void btn_stepper_start_Click(object sender, EventArgs e)
{
var thread = new Thread(() =>
{
while (true)
{
RunStepper();
}
});
thread.IsBackground = true;
thread.Start();
}
Run the function. I use Invoke to stop cross threading but you may know a better way
private void RunStepper()
{
Invoke(new Action(() =>
{
val1 = trkbr_stepper.Value;
if (val1 > 540)
{
//do some work here
// I leave this out to make code smaller for you
}
}));
}
I found I had to have this event as without it the function above did not seem to run.
private void trkbr_stepper_Scroll(object sender, EventArgs e)
{
}
My problem is the UI is still locked so I cannot scroll the taskbar. What have I missed or done wrong please?