If you implement the IBabelService Interface yourself, it is important that you understand the threading model used by the Babel Package for colorizing and parsing. All methods are called from the main thread of the Babel Package, with the exception of the IBabelService::ParseSource Method, which is called from the parse thread. The ParseSource method (parse thread) and the IBabelService::ColorLine Method (main thread) can be called simultaneously. That is, the Colorline method can be called while you are working on a call from the ParseSource method, and vice versa, but only one ParseSource and one ColorLine method call can occur at a time. The ColorLine method is suitable for a stateless implementation that just uses local variables. The ColorLine method should not share any state with the ParseSource method. Thus, you should not share any member variables of the object itself or global variables in the code between these methods. For simplification, consider using separate lexers, one for the ColorLine method and one for the ParseSource method to avoid threading problems. If you only use one lexer, then lock the use of this lexer with a critical region. The library used with the default IBabelService implementation uses this approach because lex- (or flex-) generated scanners use global variables.