I've created a button which is linked to the following function:
private void btnSetVal_Click_1(object sender, RoutedEventArgs e)
{
//VolumeMeter.Value = Convert.ToInt32(txtValue.Text);
int l_iMilSecs = 1000;
VolumeMeter.fSetVal(20);
Thread.Sleep(l_iMilSecs);
VolumeMeter.Value = 30;
Thread.Sleep(l_iMilSecs);
VolumeMeter.Value = 40;
Thread.Sleep(l_iMilSecs);
VolumeMeter.Value = 50;
Thread.Sleep(l_iMilSecs);
VolumeMeter.Value = 60;
}
The function fSetVal - updates a user control visibility. In run time the btnSetVal_Click_1 put the thread to sleep(as many times I call sleep) but only perform the last call to fSetVal.. I've tried to add the keyword volatile to the function but it doesn't even compile so it's probably not the right way to go.. Any thought how to prevent it?
fSetVal :
public void fSetVal(int p_iNewVal)
{
//Amit: Set the first X(p_iNewVal ) rectangles visible.
int l_iLastVisibleIndex = m_iNumOfRectangles - p_iNewVal -1;
for (int i = m_iNumOfRectangles - 1; i > l_iLastVisibleIndex; --i)
{
unifGridVolumeMeter.Children[i].Visibility = Visibility.Visible;
}
//Amit: Set the rest of the rectangles to invisible:
for (int i = 0; i <= l_iLastVisibleIndex; i++)
{
unifGridVolumeMeter.Children[i].Visibility = Visibility.Hidden;
}
}