Before you begin
The code fragments share one scope and assume the following:xboxLiveContextis anXblContextHandlefor the signed-in user. To create one, call XblContextCreateHandle.xboxUserIdis theuint64_tXBOX user ID (XUID) of the player whose stats you want updates for.scidis aconst char*that contains the Service Configuration ID (SCID) for your title.TotalPuzzlesSolvedis an example stat name. Replace it with the name of an event-based stat that’s configured for your title.LogToScreenis aprintf-style logging function in your app.
Add a stat-changed handler
Register an event handler for statistic change notifications by using the following example code. The event handler receives an XblStatisticChangeEventArgs object. If xboxLiveContext or the handler is null,XblUserStatisticsAddStatisticChangedHandler returns 0 and doesn’t register the handler.
Track the stats that you want updates for
Your handler receives updates only for stats that you track. Call XblUserStatisticsTrackStatistics with the users and stat names that you want updates for. You can change the set of tracked stats at any time, independently of your handlers.XblUserStatisticsSubscribeToStatisticChange and XblUserStatisticsUnsubscribeFromStatisticChange are deprecated. They still work, but they’ll be removed in a future release, and depending on your compiler settings, calls to them can produce deprecation warnings. Use XblUserStatisticsTrackStatistics and XblUserStatisticsStopTrackingStatistics instead.Stop tracking stats
When you no longer need updates for specific stats, call XblUserStatisticsStopTrackingStatistics with the same users, SCID, and stat names that you tracked.XblUserStatisticsStopTrackingStatistics.
