.net - Add code to current editor window in visual studio package/extention -


how add/remove code in code editor extension?

for example:
created extension witch modifies code incoming socket
example uses microsoft.visualstudio.text.editor

tried using:

iwpftextview textview; // got visual studio "create" event itextchange change; // got network socket or other source

itextedit edit = textview.textbuffer.createedit(); // throws "not owner" exception edit.delete(change.oldspan); edit.insert(change.newposition, change.newtext);

but guess there's way because crateedit() function fails

the problem here attempting edit on itextbuffer different thread 1 owns it. not possible. itextbuffer instances affinitized particular thread once first edit occurs , after point cannot edited different thread. takethreadownership method fail after itextbuffer has been affinitized. other non-editing methods (currentsnapshot example) can called thread.

typically itextbuffer affinitized visual studio ui thread. perform edit use original synchronizationcontext.current instance or dispatcher.currentdispatcher ui thread onto ui thread , perform edit.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -