Working with the Data Collection API in sampling mode
In previous blogs we’ve talked about using the Data Collection API to limit the amount of data that you collect in instrumentation mode. I’ve been asked recently if the Data Collection API can work with sampling mode as well as instrumentation mode.
The answer is yes, but in a limited fashion. Normally with the Data Collection API you can specify starting and stopping profiling at global, thread or process levels. But in sampling mode, you can only use global level to control profiling. For managed just add a reference to Microsoft.VisualStudio.Profiler.dll and use the DataCollection namespace. And for native code include VSPerf.h and use the functions defined in there.