I am new to C# development and wish to create a more responsive UI. In my preliminary research, I have seen two methods for achieving this:
- Multi-threading in conjunction with the BackgroundWorker class.
- The newer Async/Await modifiers.
Does newer mean better? What's the difference between the two methods? If I wish to create a new project, how do I choose which method to go with?
EDIT: Maybe I should specify. I am creating a Windows Forms application, where all necessary data will be saved/loaded on the local disk. I will also be communicating with several USB devices.
Best Answer
You will be able to accomplish your task using
BackgroundWorker
. It is a well known class, and many people have used it.The new C# 5
async
andawait
keywords basically just make it easier to write readable asynchronous code. There may be fewer tutorials and examples of how to accomplish various tasks with these keywords rather thanBackgroundWorker
.Unless you need to use an older version of C#, I suggest learning how to use
async
andawait
.