I'm writing a VS 2013 extension using Editor Margin project template. I want it to update the margin's content every second. Here's the code, it works as expected in Experimental instance of VS, but not in the normal instance:
internal class Margin: Canvas, IWpfTextViewMargin
{
public Margin(IWpfTextView textView)
{
File.AppendAllText(@"c:\logs\githere.log", "hi");
var timer = new DispatcherTimer();
timer.Tick += (o, e) => File.AppendAllText(@"c:\logs\githere.log", "wat");
timer.Interval = TimeSpan.FromSeconds(1);
timer.Start();
}
}
To localize the problem I'm writing into a file instead of updating margin's content. When I run the experimental instance, I could see wat
appearing every second, but in normal instance it only writes hi
.
What am I doing wrong?
UPD: Turns out that this code is working as expected, I must have been missed something yesterday when I was testing it. My problem is in the real Tick
handler, it throws an exception.