C# Threading Handbook

 < Day Day Up > 


Tobin Titus

Fabio Claudio Ferracchiati

Tejaswi Redkar

Srinivasa Sivakumar

Copyright © 2004 by Apress

(This book was originally published by Wrox Press in 2003.)

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.

ISBN (pbk): 1-86100-829-5

Printed and bound in the United States of America 10987654321

Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

Distributed to the book trade in the United States by Springer-Verlag New York, Inc., 175 Fifth Avenue, New York, NY, 10010 and outside the United States by Springer-Verlag GmbH & Co. KG, Tiergartenstr. 17, 69112 Heidelberg, Germany.

In the United States: phone 1-800-SPRINGER, email <orders@springer-ny.com>, or visit http://www.springer-ny.com. Outside the United States: fax +49 6221 345229, email <orders@springer.de>, or visit http://www.springer.de.

For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, email <info@apress.com>, or visit http://www.apress.com.

The information in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work.

The source code for this book is available to readers at http://www.apress.com in the Downloads section.

Credits

Authors Tobin TitusFabio Claudio FerracchiatiTejaswi RedkarSrinivasa Sivakumar

Additional Material Kourosh ArdestaniSandra GopikrishnaAndrew Polshaw

Commissioning Editors Nick ManningAndrew Polshaw

Technical Editors James HartNick ManningDouglas Patterson

Project Manager Beckie Stones

Managing Editor Emma Batch Technical Reviewers Kourosh ArdestaniRichard BonneauMark HornerCraig McQueenSaurabh NanduErick SgarbiDavid Whitney

Publisher Jan Kolasinski

Index Michael Brinkman

Production Coordinator Neil Lote

Proof Reader Chris Smith

Cover Natalie O'Donnell

About the Authors

Tobin Titus

Tobin has several years of experience in software development and in the consulting industry. He started working with BASIC in the 5th grade on an Atari 800XL computer. With the release of Visual Basic, Tobin moved to Windows programming and has been developing Windows and web-based solutions ever since. Tobin specializes in internet applications solutions with Visual Basic, Java, and now Microsoft .NET tools - VB.NET, C#, and ASP.NET. He is also authoring the BrainBench certification exam on Visual Basic .NET (www.brainbench.com). Currently, Tobin does work for some of the best companies in the world including his own - Dax Software and Consulting, LLC (www.daxsoftware.com).

Thanks go to everyone who has supported me in my career. To the staff at Bethel Christian High School in Pennsylvania and Bob Jones University in South Carolina, thank you for your unfailing faith and uncompromising positions. Thanks go to Carol, for putting up with my never-ending work schedule. Special thanks to my parents who sacrificed so much for our family. And a special loving memory to my Grandmother Helm who was always able to encourage me to do better with just a simple hug - and maybe a little taste of fudge!

Fabio Claudio Ferracchiati

Fabio Claudio Ferracchiati is a software developer and technical writer. In the early years of his ten-year career he worked with classical languages and 'old' Microsoft tools like Visual Basic and Visual C++. After five years he decided to dedicate his attention to the Internet and all the related technologies. In 1998 he started a parallel career writing technical articles for Italian and international magazines. He works in Rome for CPI Progetti Spa (http://www.cpiprogetti.it), where he develops Internet/Intranet solutions using Microsoft technologies. Fabio would like to thank Wrox for the chance to write this book.

Dedication to Danila: As in every book I write and will write, a special thank you goes to my unique love. You can't imagine how is important to have a woman like her near me in the happy and sad moments that life gives to us. I love you so much…

Tejaswi Redkar

Tejaswi Redkar is a software evangelist. He holds a Master's degree in Engineering from San Jose State University, California. His areas of interest include designing scalable multi-tiered distributed applications and new generation embedded devices. Recently he filed a patent for his innovations in managing telemetry gateways. When he is not working he can be found eating exotic food.

I would like to thank Wrox Press for giving me the opportunity to express my ideas through articles. I would also like to thank my dear wife Arohi for continuing to motivate me.

Srinivasa Sivakumar

Srinivasa Sivakumar is a software consultant, developer, and writer. He specializes in web and mobile technologies using Microsoft solutions. He currently works at Chicago for TransTech, LLC. He has co-authored various books, including Professional ASP.NET Web Services, ASP.NET Mobile Controls - Tutorial Guide, .NET Compact Framework, Beginning ASP.NET 1.0 with VB.NET, Professional ASP.NET Security, The Complete Visual C# Programmer's Reference Guide, and .NET Compact Framework. He has also written technical articles for ASP Today, C# Today, .NET Developer, and more. In his free time he likes to watch Tamil movies and listen to Tamil sound tracks (Especially ones sung by Mr. S.P Balasubramaniyam).

The book takes a top-down look at how exactly .NET executes C# code. We begin by describing what a Windows thread is, and how they relate to .NET processes, application domains, and threads. We examine thread scheduling (how the operating system decides which thread to process next), then look at how we write .NET code to work with threads. Then we look at thread synchronization, so that we can safely allow multiple threads to access the same resources. We look at some typical architectures that multithreaded programs employ, in particular thread pooling. We also examine how to debug multithreaded code. We finish with a fully worked example showing how threading can help us build a scalable, high performance network server.


 < Day Day Up > 

Категории