MKM
MKM
CC#
Created by MKM on 10/22/2024 in #help
Trying to get started with threads but UI thread giving cross thread exceptions?
I have a thread that runs infinitely and what i believe is happening is that the new thread means events run on it leading to cross threading exceptions but i dont understand why that thread cant run in the background and events stay running on the main ui thread? This is the test i am using for my new thread
private void CalculateEngineOutput() //Calculate some of the main outputs
{
while (true)
{


RevoloutionSpeed = 100 * Throttle;


}
}
private void CalculateEngineOutput() //Calculate some of the main outputs
{
while (true)
{


RevoloutionSpeed = 100 * Throttle;


}
}
and my throttle event handler is giving me threading exceptions but its on the main ui thread right?
private void TRACKBAR_Throttle_Scroll(object sender, EventArgs e) //The trackbar throttle value is changed
{
//Gets the trackbar throttle value and removes the idle value from it to find how much the throttle is actually open

if (TRACKBAR_Throttle.Value/100 <= (double)MainForm.ACCESSOR_GrabEngineObject.ACCESSOR_ATTRB_IdleThrottlePosition/100) //If the value is less than the idle throttle position
{
Throttle = (double)MainForm.ACCESSOR_GrabEngineObject.ACCESSOR_ATTRB_IdleThrottlePosition/100; //Set it to the idle throttle position
}
else
{
Throttle = TRACKBAR_Throttle.Value / 100; //Otherwise set it to the actual scroll bar value
}
}
private void TRACKBAR_Throttle_Scroll(object sender, EventArgs e) //The trackbar throttle value is changed
{
//Gets the trackbar throttle value and removes the idle value from it to find how much the throttle is actually open

if (TRACKBAR_Throttle.Value/100 <= (double)MainForm.ACCESSOR_GrabEngineObject.ACCESSOR_ATTRB_IdleThrottlePosition/100) //If the value is less than the idle throttle position
{
Throttle = (double)MainForm.ACCESSOR_GrabEngineObject.ACCESSOR_ATTRB_IdleThrottlePosition/100; //Set it to the idle throttle position
}
else
{
Throttle = TRACKBAR_Throttle.Value / 100; //Otherwise set it to the actual scroll bar value
}
}
34 replies
CC#
Created by MKM on 10/19/2024 in #help
C# Basic animation, cant get a circle to align between two lines
No description
49 replies