You should
never halt main thread or even do any lengthy processing in it. Also, as a rule of thumb, never use Application.DoEvents. You need to do nearly the opposite. You should run all your communications in a separate thread. Any communications with UI should be done via
Control.Invoke
,
Control.BeginInvoke
,
Dispatcher.Invoke
or
Dispatcher.BeginInvoke
.
See also:
Control.Invoke() vs. Control.BeginInvoke()[
^],
Problem with Treeview Scanner And MD5[
^] on generally used variants of using threads.
Yes, this
is easy enough. Don't even play with the idea to go without multi-threading, it will be a nightmare and never got you the acceptable solution.
—SA