Caching of multiple documents for editor control

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by Matt Adamson
Avatar
Guys,

I was going to implement a simple caching mechanism to cache the Document object when it's built and parses a file. Given it can take a second or two to parse a document it would be nice if it was near instantaneous when switching between files.

Do you have any specific recommendations here on how I do this or should a simple cache of the Document object and then setting this reference to the syntax editor.

Thoughts appreciated

Thanks

Matt

Comments (6)

Posted 16 years ago by Paul Fuller
Avatar
Matt,

I take a simple approach as you describe and it works very well. No problem with having multiple documents in existence and assigning them as required to an editor instance.

You even get outlining, undo/redo etc associated with each document.

Regards,

Paul
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes as Paul said, caching the Document instance and swapping it in and out of the SyntaxEditor will be fastest.


Actipro Software Support

Posted 16 years ago by Matt Adamson
Avatar
I finally managed to get around to trying to implement this ( performance low on priority :) - however when I retrieve a "Document" instance from my cache which is say keyed on an integer, the Document Text property is empty even though previous it had text in.

Any ideas?
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You maybe still have the document wired up to a SyntaxEditor before you clear it or something. Nothing in our code should delete the text. Another way you could look for what is doing this is to attach to the Document's TextChanged event and watch for when it occurs and see what causes it.


Actipro Software Support

Posted 16 years ago by Matt Adamson
Avatar
I've tried wiring up events TextChanged for the Document and neither assertion gets fired as I would expect e.g.

void rightDocument_TextChanged(object sender, DocumentModificationEventArgs e)
{
if (rightDocument.Text == String.Empty)
{
Debug.Assert(false);
}
}

I'll actually send the source code for this class direct to the support email address as don't want to share it here.
Posted 16 years ago by Matt Adamson
Avatar
Sorry guys just an update. The assert is getting fired now.

It seems the Text property of the syntax editor was getting set to String.Empty. Because the editor control links to a document this was calling the Text property on the Document instance.

It turns out I don't need to do this anyway now I'm building the Document object up separate and can simply set a reference to the cache Document instance which replaces all the text fine :)
The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.