diff --git a/src/ForceToolkitForNET/ForceClient.cs b/src/ForceToolkitForNET/ForceClient.cs index b30135cf..3feecf88 100644 --- a/src/ForceToolkitForNET/ForceClient.cs +++ b/src/ForceToolkitForNET/ForceClient.cs @@ -309,13 +309,13 @@ public async Task> RunJobAsync(string objectName, strin } public async Task> RunJobAndPollAsync(string objectName, BulkConstants.OperationType operationType, - IEnumerable> recordsLists) + IEnumerable> recordsLists, float? maxPollDelayMilliSeconds = null) { - return await RunJobAndPollAsync(objectName, null, operationType, recordsLists); + return await RunJobAndPollAsync(objectName, null, operationType, recordsLists, maxPollDelayMilliSeconds); } public async Task> RunJobAndPollAsync(string objectName, string externalIdFieldName, BulkConstants.OperationType operationType, - IEnumerable> recordsLists) + IEnumerable> recordsLists, float? maxPollDelayMilliSeconds = null) { const float pollingStart = 1000; const float pollingIncrease = 2.0f; @@ -345,6 +345,7 @@ public async Task> RunJobAndPollAsync(string objectName await Task.Delay((int)currentPoll); currentPoll *= pollingIncrease; + if (maxPollDelayMilliSeconds != null && currentPoll > maxPollDelayMilliSeconds) currentPoll = (float)maxPollDelayMilliSeconds; } diff --git a/src/ForceToolkitForNET/IForceClient.cs b/src/ForceToolkitForNET/IForceClient.cs index aa53de42..98adc3f7 100644 --- a/src/ForceToolkitForNET/IForceClient.cs +++ b/src/ForceToolkitForNET/IForceClient.cs @@ -41,7 +41,7 @@ public interface IForceClient : IDisposable // BULK Task> RunJobAsync(string objectName, BulkConstants.OperationType operationType, IEnumerable> recordsLists); - Task> RunJobAndPollAsync(string objectName, BulkConstants.OperationType operationType, IEnumerable> recordsLists); + Task> RunJobAndPollAsync(string objectName, BulkConstants.OperationType operationType, IEnumerable> recordsLists, float? maxPollDelayMilliSeconds = null); Task CreateJobAsync(string objectName, BulkConstants.OperationType operationType); Task CreateJobBatchAsync(JobInfoResult jobInfo, ISObjectList recordsObject); Task CreateJobBatchAsync(string jobId, ISObjectList recordsObject);