.NET Framework Bookmark and Share   
 index > Microsoft Codename 'Oslo' > Is DynamicParser thread-safe?
 

Is DynamicParser thread-safe?

Hi all, we have a syntax-highlighting code editor control called SyntaxEditor for WPF. We wrote afree MGrammar add-on a while back that allows an MGrammar parser to drive the syntax highlighting for the control. We've recently added features to our editor that allow a syntax/semantic parser to be automatically called when document text changes occur (like from user typing, etc.). The designated parser is called in a worker thread so that it doesn't block the UI thread.

We're about to begin work on some enhancements to our MGrammaradd-on so that the DynamicParser can harness these new features andbe called to return the parse graph asynchronously to the document being edited after text changes occur. This is going to be a great feature since it will allow devs to automatically get a parse graph they can use to show document outlines, etc. in UI, all from the text in the editor.

My question is whether it is safe to use the same DynamicParser for this parsing call? Consider that if we do it this way, the main UI thread may be using the same DynamicParser to do some quick parsing for syntax highlighting at the same time. So I'm not sure if it is "safe" to have the same DynamicParser being used from two threads at the same time or not.

If not, we can always create a second instance of the DynamicParser that should explciitly be used for the new parsing part. However it would be preferable (for memory and simplicity) to use the same instance.

Thanks for your help!
actiprosoftware.com - WPF ribbon, docking/mdi, propertygrid, navbar, explorerbar, breadcrumb, gauge, bar code, wizard controls & much more
Bill Henning
Yes it is, I have a project where I am parsing many different files at the same time with the same parser instance. Of course the results have to be dispatched back to the UI thread in your case, when you're done.
  • Marked As Answer byBill Henning Wednesday, August 12, 2009 3:45 PM
  •  
justncase80
Yes it is, I have a project where I am parsing many different files at the same time with the same parser instance. Of course the results have to be dispatched back to the UI thread in your case, when you're done.
  • Marked As Answer byBill Henning Wednesday, August 12, 2009 3:45 PM
  •  
justncase80
Great, glad to hear it. Right, our framework does dispatch the results back to the UI thread and fires off an event on the document indicating that its parse data has been updated.
actiprosoftware.com - WPF syntaxeditor, ribbon, docking/mdi, propertygrid, editors, navbar, explorerbar, breadcrumb, gauge, bar code, wizard controls & much mored
Bill Henning

You can use google to search for other answers

Custom Search

More Threads

• NONE of the Menu Buttons in Quadrant or Intellipad from Oslo May 2009 CTP do anything
• Is there any Antlr ---> MGrammar translator around?
• Quadrant can't start
• "No compilation information is available at this time"
• M Grammer default output; dropping token type
• IntelliPad Projects?
• MGrammar projections: numbers without inverted commas
• DynamicParser.LoadFromResource() and MgCompile MSBuild Task.
• CreateRepository just plain falls over...
• Model to Model transformations in Oslo, any plans?