This question has already been answered:

How to use timer in WPF?

I get the error:

InvalidOperationException was not handled by user code.

Because of a different thread of yours.

alt text

Reported as a duplicate member by VladD c # Nov 30 '16 at 20:13 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • Perhaps you should convert value to int. As far as I remember, in C #, everything in the forms is a string. - lamazavr
  • I did, but the error remained. - Angus123

2 answers 2

Try Dispatcher.Invoke . So

Dispatcher.Invoke( DispatcherPriority.Normal, new Action(() => progressBar1.Value++) ); 

Or the code which is resulted on the link in article on MSDN.

    In WPF, you must use DispatcherTimer instead of Timer. It will work in the right stream.