The Microsoft.VisualStudio.Profiler namespace enables you to programmatically control performance data collection from within the application. This approach is useful, for example, if you want to collect performance data in the scope of a function or you want to avoid gathering performance data of a larger framework in which your code is executing. Another example where this approach is useful is, if you want to gather performance data of a specific thread from a group of threads.
These APIs are not supported in Sampling mode for Windows 8 and later versions.
The DataCollection class enables you to programmatically control the amount of data collected during profiling in the .vsp file. To programmatically control data collection, use methods and property of the DataCollection class in your managed code.
CommentMarkAtProfile, CommentMarkProfile, and MarkProfile return success or failure using the MarkOperationResult enum.
NameProfile method returns NameOperationResult enum to indicate success or failure.
ProfileLevel enum is used indicate one of the three levels to which performance data collection can be applied.
ResumeProfile, StartProfile, StopProfile, and SuspendProfile return success or failure using the ProfileOperationResult enum.
In sampling mode, the following limitations exist:
Suspend/Resume is not supported.
Start/Stop at thread level not supported in sampling mode.
For information on native APIs, see VSPerf.h file.