sklose/NCalc2

Caching doesn't work in a multi threaded context

Closed this issue · 1 comments

Hi,

I noticed that NCalc often hangs when multiple threads are using it. I only use an ncalc expression object that is local to the method so I thought it should be thread safe.
My application often freezes on the line:
expression.HasErrors()
When i looked in the debug window the error was:
"Recursive read lock acquisitions not allowed in this mode"

I realized that this could have something to do with the caching in NCalc, so I turned it off by doing:
Expression.CacheEnabled = false;

When I turn caching off everything works fine.

I realize this might be a tough one to get the bottom of, but I thought it was worth mentioning it.

Let me know if you want any more info.

Kind Regards
Fredrik Dahlberg

Hi,
we experience the same issue with multi-threading and Cache enabled. Disabling the cache worked for us, too. Need to do some performance testing if it has a high impact on our overall solution.

Great work anyway, the library helps a lot in our case.
Cheers
Christoph