-
Calling "grammar.TokenizeLine(line,rulestack)" by two threads at the same time will cause thread safety problems. How do you solve them? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Each AvaloniaEdit instance uses one intance of the TMModel class to manage multithreading. It launches only one thread per grammar. |
Beta Was this translation helpful? Give feedback.
-
If I want to achieve the effect of vscode, when the code is very long, first of all, one thread of vscode will refresh the code color from the code in the visual area (the color may be wrong at this time), and then another thread will refresh the color from changing the position. At this time, there will be a phenomenon that the syntax starts two threads. In this way, you can achieve the rapid response of code color and ensure the correctness after refreshing. What should I do to achieve this effect? |
Beta Was this translation helpful? Give feedback.
-
Well this behavior is already implemented in AvaloniaEdit and it's working fine. Take a look. It parses the viewport in the UI thread and starts parsing the document in a bg thread. Every time the viewport is scrolled, the view port is re-parsed. |
Beta Was this translation helpful? Give feedback.
Each AvaloniaEdit instance uses one intance of the TMModel class to manage multithreading.
It launches only one thread per grammar.