On 9/6/2012 8:22 AM, Registered User wrote:
> On Wed, 5 Sep 2012 00:04:18 -0700 (PDT), archana <(E-Mail Removed)>
> wrote:
>> Need some suggestion on implementating locking mechanism.
>> currently i have multple asynchronous request which have one callback
>> function. In callback , i am traverssing through dictionary and adding
>> into some shared dictionary, Callback is shared accross multiple
>> thread. So to prevent more than one thread trying to add to sharred
>> dictionary i have enclosed in lock statement.
>>
>> But I am thinking of removing lock statment from entire callback and
>> adding lock statment only when looking into shared resource and adding
>> to shared resource.
>>
> In .NET 4 the System.Collections.Concurrent namespace contains several
> thread-safe data structures.
> <http://msdn.microsoft.com/en-us/library/system.collections.concurrent.aspx>
> http://msdn.microsoft.com/en-us/libr...oncurrent.aspx
Note that thread safe here is used in the traditional meaning: thread
safe for single operations.
In some multi operations scenarios explicit locking is still
necessary.
Arne