Chapter 12 – Improving Performance and Scalability with Multitasking
- By convention, what suffix should be applied to a method that returns a
Task
or aTask<T>
?Async, for example,
OpenAsync
for a method namedOpen
. - To use the
await
keyword inside a method, which keyword must be applied to the method declaration?The
async
keyword must be applied to the method declaration. - How do you create a child task?
Call the
Task.Factory.StartNew
method with theTaskCreationOptions.AttachToParent
option to create a child task. - Why should you avoid the
lock
keyword?The
lock
keyword does not allow you to specify a timeout; this can cause deadlocks. UseMonitor.Enter
with aTimeSpan
andMonitor.Exit
instead. - When should you use the
Interlocked
class?If you have integers and floats that are shared between multiple threads, you should use the
Interlocked
class.