I am using an int for a timer countdown in my application like this:
public partial class CardsTabPage : ContentPage
{
public int timer1Seconds;
Later in the code there's a while look like this:
while (timer1Seconds > 0) & reposition == null)
{
// some actions
await Task.Delay(100);
timer1Seconds--;
}
The timer counts down but I also have a part of the code that responds to a button click or leaving a page that sets the value of timer1Seconds to 0 to immediately stop the while loop.
I just learned about volatile. Would this be a candidate for me to change the definition to
volatile int timer1Seconds
Also if I do change it the is that still public and just specific to the class or would that now be a variable I could access anywhere?