Reputation: 4328
Hi every one i have a phenomenal situation. My firstly code like this :
public MainPage()
{
// Required to initialize variables
InitializeComponent();
Intro I = new Intro();
I.BuatUI();
LayoutRoot.Children.Add(I.GridIntro);
}
But when i add dispatcher timer. My silverlight program not work. only out a loading and never come the main program
private DispatcherTimer generalTimer;
public MainPage()
{
// Required to initialize variables
InitializeComponent();
Intro I = new Intro();
I.MakeUI();
LayoutRoot.Children.Add(I.GridIntro);
generalTimer.Interval = TimeSpan.FromSeconds(2);
generalTimer.Start();
generalTimer.Tick += new EventHandler(delegate(object s, EventArgs a)
{
LayoutRoot.Children.Remove(I.GridIntro);
IsiIdentitas();
generalTimer.Stop();
});
}
In my visual studio the private DispatcherTimer generalTimer have green line it said the generalTimer never used.
please help me solve my problem
Upvotes: 0
Views: 274
Reputation: 1503489
You're never assigning a value to generalTimer
, so it will still be null
when you try to use it. Try this:
generalTimer = new DispatcherTimer();
just before you start assigning values to the properties (or at the point of declaration).
Upvotes: 1