Your question is very rightful: you need to redesign you code completely to use thread. Write noe, it is not multithreaded. Don't even play with the idea to go along without threads.
It's good that you are familiar with
Dispatcher
, but you misused it. Dispatcher is only usable when you have UI thread and want to trigger some operation from the other thread. I provided detail explanations and basic usage directions here:
Control.Invoke() vs. Control.BeginInvoke()[
^].
As a rule of thumb, using DispatcherPriority is pointless. Better don't touch any priorities, until you know exactly why you do it, which would be quite a rare case.
For a similar case of use of a thread, see this:
Problem with Treeview Scanner And MD5[
^].
Basically, you need to create at least one thread to carry out all your timely operations. Thread should not use spin-wait: there are thread synchronization primitives to make a thread waiting without wasting CPU time. The UI should only feed the task to the thread. One general method of doing that is sending messages via blocking queue. Please see my Tips/Tricks article on the topic:
Simple Blocking Queue for Thread Communication and Inter-thread Invocation[
^].
For starting a thread, passing any parameters I strongly recommend using a thread wrapper; please see this:
How to pass ref parameter to the thread[
^].
You need to try to re-design the application to be based on threading. Ask further Questions if your face any problems.
—SA