Can a client API call take a cancellation token so that the client can cancel his API call at a later moment?
var cancelsource = new CancellationTokenSource(); var token = cancelsource.Token;
For example:
The player calls PlayFabClientAPI.UpdateUserDataAsync and the API call takes much longer than usual to complete. In this special case, the API call could be canceled automatically with a cancellation token.
Is it possible to use cancelsource.Token with PlayFabClientAPI.UpdateUserDataAsync to cancel the API call if the API call doesn't respond normally?
Or is it not necessary to use a cancellation token in this case? Will result.Error have an error message if a PlayFab call takes too much time to complete?
private static async Task UpdatePlayerCountryData(string country, string city) { var cancelsource = new CancellationTokenSource(); var token = cancelsource.Token; var result = await PlayFabClientAPI.UpdateUserDataAsync(new PlayFab.ClientModels.UpdateUserDataRequest() { Data = new Dictionary<string, string>() { {"Country", country}, {"City", city} }, Permission = PlayFab.ClientModels.UserDataPermission.Public }); if (result.Error != null) Console.WriteLine(result.Error.GenerateErrorReport()); else Console.WriteLine("Successfully updated user data"); }