Saving stats to file

One question, in order to get these stats with this code, do you need to run it in the stats thread? If so, how did you accomplish that?

Thanks,

Franco