SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 175 | Next

Robin Pars, Laurence Moroney, and John Grieb

"Foundations of ASP.NET AJAX"

NET AJAX 111
and the S&P is set to 1400. There will also be some simple logic to update the display
values of those indices with some fictitious data as shown in the following code block in
the code-behind class:
protected void Timer1_Tick(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(1000);
lblDowJones.Text = ((int.Parse(lblDowJones.Text)) + 1).ToString();
lblNasdaq.Text = ((float.Parse(lblNasdaq.Text)) + 0.5).ToString();
lblSnp.Text = ((float.Parse(lblSnp.Text)) + 0.25).ToString();
}
First, you initiate a one-second delay by pausing the current thread, and then you
increment the values of each label control by holding the value for the market indices
and assigning them back to the corresponding labels. As you can see, the value for DJIA
is incremented by one point, the NASDAQ index is incremented by a half point, and the
S&P 500 index is incremented by a quarter point. This update effectively takes place every
three seconds because the Timer1_Tick event is called every two seconds followed by a
one-second delay in the method.
Figure 6-2 shows MarketData.


Pages:
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187