Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Asynchronously loading documents in AvalonEdit

$
0
0

Hi,

I have extended my editor about a month ago to initially load text in an asynchronous task because I thought this should speed up the start of the application (https://edi.codeplex.com/). So, I implemented the asyn load unsing the Task Library and got the exception from the TextDocument class about the thread not being owned and so forth. I was not able to follow the hint about the SetOwner method since I do not know what method this refers to and how to apply it in my case - does this work with a thread created with the Task Library (?):

 

So, I caved in and used a lock(lockObject) { } approach instead:

https://edi.codeplex.com/SourceControl/latest#ICSharpCode.AvalonEdit/Document/TextDocument.cs

...and made some minor adjustments...

https://edi.codeplex.com/SourceControl/latest#ICSharpCode.AvalonEdit/Document/DocumentLine.cs

I guess, I am having 2 questions now:

1) How would I use this SetOwner method correctly in my case? Can you give me a reference to the class and maybe some sample code?

2) The second question is about the lockObject solution. Do you see any trouble in this approach? I've been using this for a month or so now and I could not find any problem at all, but maybe I am not using it in the way where it could break...(?)

Any kind of feedback on this would be great.

 

Next I'd like to make the initial highlighting an async task that can be cancelled, but thats not happening until after I know what I have so far is good as it is :-)


Viewing all articles
Browse latest Browse all 1764

Trending Articles