jehugaleahsa / mustache-sharp

An extension of the mustache text template engine for .NET.
The Unlicense
306 stars 78 forks source link

Can the PropertyDictionary be made thread-safe #28

Closed jaydrozd closed 10 years ago

jaydrozd commented 10 years ago

I ran into an issue where my application had hung due to high CPU usage, and it turns out that the runaway threads were all trying to access the PropertyDictionary.getCacheType.

The lock occurred in the TryGetValue (_cache.TryGetValue in PropertyDictionary.cs - Line 41).

Of course, easiest solution would be to use ConcurrentDictionary, but that is only available in .net 4.0. We could possibly use a lock to make sure only one thread can access this static dictionary at a time.

jehugaleahsa commented 10 years ago

There should definitely be a lock in there. I am not sure why this would cause your threads to lock. I would expect it to throw an exception.

jehugaleahsa commented 10 years ago

I have added a lock around the PropertyDictionary class and have recreated the NuGet package. Reopen the issue if your problem does not go away.