The code makes no sense, but probably you need to process some real data and notify the progress in UI later on.
You need an extra thread, nothing else (don't repeat common fallacy, don't use timers)!
Create a separate thread. This is a code sample for a very robust way:
How to pass ref parameter to the thread[
^].
You cannot call anything related to UI from non-UI thread. Instead, you need to use the method
Invoke
or
BeginInvoke
of
System.Windows.Threading.Dispatcher
(for both Forms or WPF) or
System.Windows.Forms.Control
(Forms only).
You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[
^],
Problem with Treeview Scanner And MD5[
^].
See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[
^],
Control events not firing after enable disable + multithreading[
^].
—SA