I just noticed this. Debug.Print significantly slows down the code when the debugger is not attached. Attach the debugger and everything returns to normal.
On my Spider with Latest Framework 4.2, the below contrived example demonstrates the problem
Notice: I put the Debug.Print in a loop just to exaggerate the problem. With the debugger attached the elapsed time is very close to the expected 1000ms, but as soon as the debugger detaches the time jumps to around 5000ms. Attach the debugger and the queued timer ticks fire in quick succession to catchup and then everything returns to normal hovering around 1000ms.
Is this expected to have such a dramatic slowdown 4 seconds to execute 10 Debug.Print statements?
using Microsoft.SPOT;
using GT = Gadgeteer;
using System;
namespace Spider42Test
{
public partial class Program
{
GT.Timer _timer = new GT.Timer(1000);
Font _font;
DateTime _lastTime;
void ProgramStarted()
{
_font = Resources.GetFont(Resources.FontResources.NinaB);
_timer.Tick += new GT.Timer.TickEventHandler(_timer_Tick);
_lastTime = DateTime.Now;
_timer.Start();
Debug.Print("Program Started");
}
void _timer_Tick(GT.Timer timer)
{
TimeSpan period = DateTime.Now - _lastTime;
_lastTime = DateTime.Now;
long elapsedSeconds = period.Ticks / TimeSpan.TicksPerMillisecond;
display_T35.SimpleGraphics.ClearNoRedraw();
display_T35.SimpleGraphics.DisplayText(elapsedSeconds.ToString(), _font, GT.Color.Red, 0, 0);
for (int i = 0; i < 10; i++)
{
Debug.Print(elapsedSeconds.ToString());
}
}
}
}