I’m getting this Exception
System.InvalidOperationException was unhandled by user code Message=’The calling thread cannot access this object because a different thread owns it.’
whenever I run the following code
public partial class MainScreen : Window { Timer trm; public MainScreen() { InitializeComponent(); trm = new Timer(1000); trm.AutoReset = true; trm.Start(); trm.Elapsed += new ElapsedEventHandler(trm_Elapsed); } void trm_Elapsed(object sender, ElapsedEventArgs e) { lblTime.Content = System.DateTime.Now; } }
guys any solution… I badly wann come out of it 🙁
Use DispatcherTimer instead: