Question

I am working on C# Windows Application and I need to communicate with a device. While I need to send command to device and receive response from it. In this feature I need to continuously send command and receive response from the device. \

For this which will be better to use , background worker or thread?

Was it helpful?

Solution

Backgroundworker has its own advantages like it uses thread from Thread Pool and it is for specific purpose, which is to do time consuming job in the background, also it is very easy to use. In Backgroundworker you have RunWorkerCompleted event which will be on the main thread, so you can update your view in that. And expensive stuff you can run under DoWork event. DoWork run on the background thread from the Thread Pool.

I need to continuously send command and receive response from the device.

For your requirement, I suggest you to check TaskSheduler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top