I write next code:
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += (object sender, EventArgs e) =>
{
//...
};
timer.Start();
But I wanna write this more simply with the intializer.
So, I tried this:
new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(1),
Tick += (object sender, EventArgs e) =>
{
//...
}
}.Start();
But it occurs errors(CS0103, CS0747).
Is it impossible expression?