Thanks for the quick response!
Regarding the Parser being thread-safe.. I meant that MY usage of Parser (as a static object) was not thread-safe, not necessarily the Parser object itself. This was entirely due to my lack of understanding of the Irony object model. Speaking of which...
Can you point me to any samples/snippets of how to properly set up a Parser (static LanguageData and ParsingContext I presume) that will be used in a multi-threaded environment?
Currently, I have my Grammer as a static object and create a new Parser for each text function i need to parse in a given thread (you can view the
source here). So a thread might get a chunk of text like this:
@if([Start Date Override Text]=="none",@formatdate([Start Date],"dddd MMMM d"),[Start Date Override Text])
<p>@if([More Info URL]=="none"," ","<a href='[More Info URL]'>MORE INFO</a>")</p>
I first use Regex to grab the funtions to parse, in this case:
- @if([Start Date Override Text]=="none",@formatdate([Start Date],"dddd MMMM d"),[Start Date Override Text])
- @if([More Info URL]=="none"," ","<a href='[More Info URL]'>MORE INFO</a>")
These are then parsed with a new instance of the Parser per function. I then store the ParseTrees for each function (to avoid the cost of re-parsing the same function) in memory (static Dictionary).
I'm sure there is plenty I could refactor in order to gain efficiency and stability, I'm open to any suggestions.