m.
Ok...here we go...
The variables you are changing and checking are different variables - they are not related in any way to each other.
public static void Method_8()
{
while (method_state_6 && method_state_7 == true)
{
int p = 1;
flooddrain.Write(false);
Thread.Sleep(15 * MinuteMs);
flooddrain.Write(true);
Thread.Sleep(1 * HourMs);
int p = 0;
Thread.Sleep(1 * MinuteMs);
}
}
When you write
int p = 1;
you declare a brand new, local variable that exists only within the method, and cannot be accessed outside it. We can ignore the second declaration since it won't compile with that in there anyway, even if you are setting it to zero this time.
public static void Method_11()
{
heater.Write(false);
for (int i = 0; i < 14; i++)
{
Thread.Sleep(1 * DayMs);
If (p == 0);
{
solenoid.Write(false);
Thread.Sleep(20 * SecondMs);
solenoid.Write(true);
}
}
heater.Write(true);
}
This method uses a different
p
which is (presumably) declared at class level, but which has nothing to do whatsoever with the one in Method_8
If you want to do something like this, then you need to make sure that both threads are looking at the same variable (and by preference use a lock to make it all a bit safer)