So basically I\'m using C# to write a port scanning WPF application, that will scan over a thousand combinations of ports and IPs (x.x.x.x:xx). As a result, I have to split this
I think BackgroundWorker is better choice. In WPF, you are not allowed to make changes to the UI from another thread. So, simply moving code in the event handler method causes a problem when reflecting process result on UI (e.g. showing message "done").
It is still the same in BackgroundWorker.DoWork, but BackgroundWorker's ReportProgress and RunWorkerCompleted can help you to have your code simple. Have a look at the answer here. I think you can get the point easily.