I make a stopwatch that should work in a separate thread from the GUI, but output time in the label . The stopwatch should work in parallel with the rest of the GUI operations:
DateTime date; private void button1_Click(object sender, EventArgs e) //запуск таймера { System.Timers.Timer timer = new System.Timers.Timer(10); timer.Elapsed += timer_Elapsed; timer.Start(); } void timer_Elapsed(object sender, ElapsedEventArgs e) { date = DateTime.Now; long tic = DateTime.Now.Ticks - date.Ticks; DateTime stopwath = new DateTime(); stopwath = stopwath.AddTicks(tic); label1.Text = string.Format("{0:HH:mm:ss:ff}", stopwath); } The error is СrossThreadMessagingException . How to fix it?