This topic covers threading common issues, best practices and how to implement multi-threading application correctly
This quiz is in C# .NET quiz collection.
Start quizA thread can be seen as a virtualized CPU
Using multiple threads can neither improve responsiveness, nor enable you to make use of multiple processors
The Thread class can be used if you want to create your own threads explicitly. Otherwise, you can use the ThreadPool to queue work and let the runtime handle things.
A Task object encapsulates a job that needs to be executed. Tasks are the recommended way to create multithreaded code.
The Parallel class can not be used to run code in parallel.
PLINQ is an extension to LINQ to run queries in parallel.
The new async and await operators can be used to write asynchronous code more easily.
Concurrent collections can be used to safely work with data in a multithreaded (concurrent access) environment.
You have a lot of items that need to be processed. For each item, you need to perform a complex calculation. Which technique should you use?
You are creating a complex query that doesn’t require any particular order and you want to run it in parallel. Which method should you use?
You are working on an ASP.NET application that retrieves some data from another web server and then writes the response to the database. Should you use async/await?
When accessing shared data in a multithreaded environment, you do not need to synchronize access to avoid errors or corrupted data.
Use the lock statement on a private object to synchronize access to a piece of code.
You can use the Interlocked class to execute simple atomic operations.
You can cancel tasks by using the CancellationTokenSource class with a CancellationToken.
You are implementing a state machine in a multithreaded class. You need to check what the current state is and change it to the new one on each step. Which method do you use?
You need to implement cancellation for a long running task. Which object do you pass to the task?
© 2017 QuizBucket.org