0

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.

vorou
  • 1,869
  • 3
  • 18
  • 35
  • What thread is it running in in the normal instance? – SLaks Jun 29 '14 at 02:38
  • it turns out this code is actually working in both exp and normal instances, although I'm sure it wasn't yesterday. it must have been moon rays or something. so, the actual problem is in my `Tick` handler (it throws an exception), not in the timer. sorry to have bothered you. – vorou Jun 29 '14 at 11:28

0 Answers0