In this chapter, we’ll look at two advanced features that you can take advantage of as a Microsoft Visual C# developer: writing multithreaded code and using unsafe code. The first section of the chapter demonstrates how to write multithreaded programs that perform work asynchronously. Multithreaded applications are often more efficient than applications that use a single thread, especially when they’re executed on more advanced hardware with multiple processors. You’ll learn how to create and manage threads with the classes in the .NET Framework, as well as use classes and techniques to safely synchronize the work performed by multiple threads.
The second section of this chapter discusses how you can gain direct access to memory locations via pointers in C#. The C# language allows you to designate portions of your code as unsafe; any code in these regions is allowed to use pointers, much as is done in a C or C++ program. Although you rarely need to take advantage of unsafe code, it’s a good tool to have available if you need it.