Timers aren't particularly exact, so the best way to do this if you actually want 100 samples per second is something like this:
private class Result
{
public double X { get; set; }
public double Y { get; set; }
public double Z { get; set; }
}
private Result lastResult;
void wiimote_WiimoteChanged(object sender, WiimoteChangedEventArgs e)
{
Result newResult = new Result {
X = e.WiimoteState.AccelState.Values.X,
Y = e.WiimoteState.AccelState.Values.Y,
Z = e.WiimoteState.AccelState.Values.Z,
}
lastResult = newResult;
}
void MainLoop()
{
DateTime nextResultTime = DateTime.Now.AddMilliseconds(10);
while(true)
{
if (DateTime.Now >= nextResultTime)
{
AddResult(lastResult);
nextResultTime = nextResultTime.AddMilliseconds(10);
}
else
{
Thread.Sleep(1);
}
}
}
Just run MainLoop on a background thread (this might not be necessary if the wii events fire on a background thread).
This will get you exactly 100 samples per second unless the machine just can't handle doing AddResult that fast. In that case I think you have to lighten the load inside AddResult and do some post processing after you have captured your data - either the machine is fast enough to do it real time or it just isn't.