Async Support
NCalc supports asynchronous evaluating an expression. Unlike popular belief, async is not faster than sync, but scales better.
It's recommended to use async if your expression is doing any CPU or IO bound work at some dynamic function or parameter, so your UI don't freeze or your web-server do can another things.
Learn more about async in this article.
In Allied Bits NCalc, asynchronous classes are included in the same package and assembly as the regular ones.
Install
dotnet add package NCalc
Usage
var expression = new AsyncExpression("database_operation('SELECT FOO') == 'FOO'");
expression.Functions["database_operation"] = async (args) => {
// My heavy database work.
await Task.Delay(100);
return "FOO";
};
var result = await expression.EvaluateAsync();
Debug.Assert(true,result);