private async Task LoadGroups()
        {
            var tries = 30;

            FaceGroups.Clear();

            while (tries-- > 0)
            {
                try
                {
                    var groups = await faceServiceClient.ListLargePersonGroupsAsync();

                    foreach (var grp in groups)
                    {
                        FaceGroups.Add(new LargePersonGroupExtended {
                            Group = grp
                        });
                    }
                    MainWindow.Log("Found {0} groups.", groups.Length);
                    break;
                }
                catch (Exception exc)
                {
                    MainWindow.Log($"Error loading groups: {exc.Message}. Retry in 1 second.");
                    await Task.Delay(1000);
                }
            }
            if (tries == 0)
            {
                MainWindow.Log($"Failed to load the groups after 30 tries.");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the groups.
        /// </summary>
        /// <returns></returns>
        private async Task LoadGroups()
        {
            FaceGroups.Clear();

            var groups = await RetryHelper.OperationWithBasicRetryAsync(async() => await
                                                                        _faceServiceClient.ListLargePersonGroupsAsync(),
                                                                        new[] { typeof(FaceAPIException) },
                                                                        traceWriter : _mainWindowLogTraceWriter);

            foreach (var grp in groups)
            {
                FaceGroups.Add(new LargePersonGroupExtended {
                    Group = grp
                });
            }

            MainWindow.Log("Found {0} groups.", groups.Length);
        }
        /// <summary>
        /// Loads the groups.
        /// </summary>
        /// <returns></returns>
        private async Task LoadGroups()
        {
            FaceGroups.Clear();

            var groups = await RetryHelper.OperationWithBasicRetryAsync(async() => await
                                                                        _faceServiceClient.ListLargePersonGroupsAsync(),
                                                                        new[] { "RateLimitExceeded" },
                                                                        traceWriter : _mainWindowLogTraceWriter);

            foreach (var grp in groups)
            {
                FaceGroups.Add(new LargePersonGroupExtended {
                    Group = grp
                });
            }

            PropertyChanged(this, new PropertyChangedEventArgs("HasNoGroups"));
            MainWindow.Log("Found {0} groups.", groups.Length);
        }