Chapter 12 – Improving Performance and Scalability with Multitasking
- By convention, what suffix should be applied to a method that returns a
Taskor aTask<T>?Async, for example,
OpenAsyncfor a method namedOpen. - To use the
awaitkeyword inside a method, which keyword must be applied to the method declaration?The
asynckeyword must be applied to the method declaration. - How do you create a child task?
Call the
Task.Factory.StartNewmethod with theTaskCreationOptions.AttachToParentoption to create a child task. - Why should you avoid the
lockkeyword?The
lockkeyword does not allow you to specify a timeout; this can cause deadlocks. UseMonitor.Enterwith aTimeSpanandMonitor.Exitinstead. - When should you use the
Interlockedclass?If you have integers and floats that are shared between multiple threads, you should use the
Interlockedclass.