index > Visual C# General > Article on Threading in C#

Article on Threading in C#

I've written an extensive document on threading in C#:

http://www.albahari.com/threading

It started out as a chapter in a book that I'm writing, but ended up outgrowing the book! So I'm making it free and maintaining it in parallel as a separate project.

Any feedback would be welcome.

I'm particularly interested in comments in regard the Wait and Pulse section. I'm proposing a design pattern that makes Wait and Pulse as simple to use as an AutoResetEvent (well, almost!)

Here's what's covered:

Getting Started
Overview and Concepts
Creating and Starting Threads

Basic Synchronization
Synchronization Essentials
Locking and Thread Safety
Interrupt and Abort
Thread State
Wait Handles
Synchronization Contexts

Using Threads
Apartments and Windows Forms
BackgroundWorker
ReaderWriterLock
Thread Pooling
Timers
Local Storage

Advanced Topics
Non-Blocking Synchronization
Wait and Pulse
Suspend and Resume
Aborting Threads


Regards,
Joe Albahari

Joe Albahari
Nice article.
PradeepC

Joe,

I greatly appreciate you posting the ebook on async / threading in .NET !!

I am struggling with what I believe is are very common async requirements and would like to consider any suggestions you have:

Scenario #1

Execute a SQL statement (constructed with ad hoc query builder tool) using System.Data.SqlClient classes and allow the user to abort the SQL statement if it takes longer to run than they are willing to wait.

Scenario #2

Same as #1, except that the SQL statement is first sent to a web service and then executed from the web server.

Thanks again,
-Mike Graham
Technical Media, LLC
Row Level Security for SQL Server 2005




Data Nomad: Row Level Security for SQL Server http://www.technicalmedia.com http://www.DataNomad.com
Mike Graham
Hi Mike

>Scenario #1

>Execute a SQL statement (constructed with ad hoc query builder tool) using System.Data.SqlClient classes and allow the user to abort the SQL statement if it takes longer to run than they are willing to wait.


With this you have two options: either specify a CommandTimout or call Cancel on the SqlCommand object executing the query. In order to call Cancel, you would have to execute the command on another thread (eg with BackgroundWorker), so the main (UI) thread can service the Cancel button and call the SqlCommand object's Cancel method.

Joe Albahari
reply 4

You can use google to search for other answers

 

More Articles

• Using VB's Application Framework in C#
• Cuztomize Win Form look
• Create Word Documents By C#
• how to use switch to judge range values
• Session problem
• Bitmap(string) constructor throws ArgumentException
• Create Excell sheets
• C# - Maximum Project Name Length
• How to POST data and retrive the html respond?
• Urgent help needed with C# equivalent for Javascript escape funct...
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• object type cannot be converted to targe
• dissapearing shapes, ponits
• C# -> Excel formatting problem
• popups
• How to merge the print documents
• Checking for ilegal symbols in a string.
• Convert hex to character
• Execute Macro Excel 2000 automation c# -
• edit AppSettings
• Recieve data
• How I can add button efects?
• how to down load vsto
• Creating TCP SYN Flood C#
• Application not responding
• Launch from IStillImage freezes the app

Hot Articles

• DB permission failed
• Web Progress Bar
• passing a string (varchar) to a stored p
• Button_Click Event
• About WMI
• Add "Help" button
• Can Generics solve problem of cross refe
• how to get the selected index of a Child
• Counting words
• ValidationEventHandler
• Forcing VS2K5 not to use partial classes
• tow ArrayLists values
• convert from decimal(base-10) to alphanu
• Installing Project
• Some question about messagebox

Recommend Articles

• How do you se the default size of a cust
• How can I use C++ code in visual C# appl
• The event handler Keypress doesn't start
• AxSHDocVw
• ListView
• Socket programming
• Strong Name Key File
• How to convert DateTime to Double?
• Media Player
• Generate multiple Bitmaps in memory
• Serialization
• Can't run an application from a service.
• What differences are there for the two k
• Help! My .cs Code Behind files have vani
• Strange PathPointType = 163