コード例 #1
0
        private void requestUpdates(DataCache dataCache, MergeRequestKey?mrk, int interval, Action onUpdateFinished,
                                    DataCacheUpdateKind kind = DataCacheUpdateKind.MergeRequestAndDiscussions)
        {
            bool needUpdateMergeRequest = kind.HasFlag(DataCacheUpdateKind.MergeRequest);
            bool needUpdateDiscussions  = kind.HasFlag(DataCacheUpdateKind.Discussions);

            bool mergeRequestUpdateFinished = !needUpdateMergeRequest;
            bool discussionUpdateFinished   = !needUpdateDiscussions;

            void onSingleUpdateFinished()
            {
                if (mergeRequestUpdateFinished && discussionUpdateFinished)
                {
                    onUpdateFinished?.Invoke();
                }
            }

            if (needUpdateMergeRequest)
            {
                dataCache?.MergeRequestCache?.RequestUpdate(mrk, interval,
                                                            () =>
                {
                    mergeRequestUpdateFinished = true;
                    onSingleUpdateFinished();
                });
            }

            if (needUpdateDiscussions)
            {
                dataCache?.DiscussionCache?.RequestUpdate(mrk, interval,
                                                          () =>
                {
                    discussionUpdateFinished = true;
                    onSingleUpdateFinished();
                });
            }
        }
コード例 #2
0
ファイル: MainForm.Async.cs プロジェクト: BartWeyder/mrHelper
        async private Task checkForUpdatesAsync(MergeRequestKey?mrk,
                                                DataCacheUpdateKind kind = DataCacheUpdateKind.MergeRequestAndDiscussions)
        {
            bool updateReceived    = false;
            bool updatingWholeList = !mrk.HasValue;

            string oldButtonText = buttonReloadList.Text;

            if (updatingWholeList)
            {
                onUpdating();
            }
            requestUpdates(mrk, 100,
                           () =>
            {
                updateReceived = true;
                if (updatingWholeList)
                {
                    onUpdated(oldButtonText);
                }
            },
                           kind);
            await TaskUtils.WhileAsync(() => !updateReceived);
        }