Google


   


You are here: CodeIdol.com > C# > C# Cookbook, 2nd Edition > Threading And Synchronization

SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

C# Cookbook, 2nd Edition



Problem: Static fields, by default, are shared between threads within an application domain. You need to allow each thread to have its own nonshared copy of a static field, so that this static field can be updated on a per-thread basis. Solutio...



Problem: You need to provide thread-safe access through accessor functions to an internal member variable. The following NoSafeMemberAccess class shows three methods: ReadNumericField, IncrementNumericField, and ModifyNumericField. While all of the...



Problem: An exception thrown in a spawned worker thread will cause this thread to be silently terminated if the exception is unhandled. You need to make sure all exceptions are handled in all threads. If an exception happens in this new thread, you ...



Problem: While an asynchronous delegate is executing, you need to continuously poll it to see whether it has completed. This ability is useful when you need to monitor the length of time it takes the asynchronous delegate to execute. It can also be ...



Problem: You want an asynchronous delegate to operate only within an allowed time span. If it is not finished processing within this time frame, the operation will time out. If the asynchronous delegate times out, it must perform any cleanup before ...



Problem: You need a way of receiving notification from an asynchronously invoked delegate that it has finished. However, it must be more flexible than the notification schemes in the previous two recipes (Recipes 18.4 and 18.5). This scheme must all...



Problem: Your application will be creating many threads from the thread pool. When creating a thread from this pool, you want to be informed as to whether a thread in the pool is available or if the request for a new thread will have to be queued. B...



Problem: You have one of the following timer configuration needs: You want to use a timer to call a timer callback method at a fixed time after the timer object has been created. Once this callback method has been called the first time, you want to...



Problem: You want to store thread-specific data discovered at runtime. This data should be accessible only to code running within that thread. Solution: Use the AllocateDataSlot, AllocateNamedDataSlot, or GetNamedDataSlot method on the Thread ...



Problem: You have a resource you want only a certain number of clients to access at a given time. Solution: Use a semaphore to enable resource-counted access to the resource. For example, if you have an Xbox and a copy of Halo2 (the resource) ...



Problem: You have two processes or appdomains that are running code with actions that you need to coordinate. Solution: Use a named Mutex as a common signaling mechanism to do the coordination. A named Mutex can be accessed from both pieces of...



Problem: You have multiple threads that need to be served by a server but only one can be served at a time. Solution: Use an AutoResetEvent to notify each thread when it is going to be served. For example, a diner has a cook and multiple waitr...



Problem: You want to have code running in worker threads, or in other processes or appdomains, to be able to wait on an event. Solution: Use the EventWaitHandle class, new to the 2.0 Framework. With it, you can create a named event that will a...



Problem: You are operating on data from multiple threads and want to insure that each operation is carried out fully before performing the next operation from a different thread. Solution: Use the Interlocked family of functions to insure atom...


SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

You are here: CodeIdol.com > C# > C# Cookbook, 2nd Edition > Threading And Synchronization


ADBRITE ads links
   
Related tags







Popular Categories
Unix books and guides

AJAX popular information
C# language guides
Windows books and cookbooks

.......








Business Key Top Sites

be number one
rate your site




    С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.

    Русский Polski Francais Deutsch
    support sitemap terms

© CodeIdol Labs, 2007 - 2009