I want to create a WinForm application that must draw data coming from a socket.
I want to put the code reading from a socket in a separate thread and I am aware of the InvokeRequired/BeginInvoked pattern.
Which type of C# thread is the most suited for my purpose considering the WinForm scenario? Is it enough a common System.Threading.Thread entirely dedicated to reading data from socket or other types like BackgroundWorker? Or should I consider something else?
Is this thread running for a long time? If you need it to run for a long time, and if you don’t need to directly interact with a GUI (maybe cache data to a buffer), then I would use System.Threading.Thread. I have been using BackgroundWorker and found that, while it allows you to update the GUI via its event, it uses the .NET threadpool. The threadpool has a finite amount of threads available, so if you need to use Windows Workflow or lots of delegates via BeginInvoke, you could hurt application performance by tying up too many threadpool threads.