OpenTween.TweenMain.TimerTimeline_Elapsed C# (CSharp) Method

TimerTimeline_Elapsed() private method

private TimerTimeline_Elapsed ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private async void TimerTimeline_Elapsed(object sender, EventArgs e)
        {
            if (homeCounter > 0) Interlocked.Decrement(ref homeCounter);
            if (mentionCounter > 0) Interlocked.Decrement(ref mentionCounter);
            if (dmCounter > 0) Interlocked.Decrement(ref dmCounter);
            if (pubSearchCounter > 0) Interlocked.Decrement(ref pubSearchCounter);
            if (userTimelineCounter > 0) Interlocked.Decrement(ref userTimelineCounter);
            if (listsCounter > 0) Interlocked.Decrement(ref listsCounter);
            if (usCounter > 0) Interlocked.Decrement(ref usCounter);
            Interlocked.Increment(ref refreshFollowers);

            var refreshTasks = new List<Task>();

            ////タイマー初期化
            if (ResetTimers.Timeline || homeCounter <= 0 && this._cfgCommon.TimelinePeriod > 0)
            {
                Interlocked.Exchange(ref homeCounter, this._cfgCommon.TimelinePeriod);
                if (!tw.IsUserstreamDataReceived && !ResetTimers.Timeline)
                    refreshTasks.Add(this.GetHomeTimelineAsync());
                ResetTimers.Timeline = false;
            }
            if (ResetTimers.Reply || mentionCounter <= 0 && this._cfgCommon.ReplyPeriod > 0)
            {
                Interlocked.Exchange(ref mentionCounter, this._cfgCommon.ReplyPeriod);
                if (!tw.IsUserstreamDataReceived && !ResetTimers.Reply)
                    refreshTasks.Add(this.GetReplyAsync());
                ResetTimers.Reply = false;
            }
            if (ResetTimers.DirectMessage || dmCounter <= 0 && this._cfgCommon.DMPeriod > 0)
            {
                Interlocked.Exchange(ref dmCounter, this._cfgCommon.DMPeriod);
                if (!tw.IsUserstreamDataReceived && !ResetTimers.DirectMessage)
                    refreshTasks.Add(this.GetDirectMessagesAsync());
                ResetTimers.DirectMessage = false;
            }
            if (ResetTimers.PublicSearch || pubSearchCounter <= 0 && this._cfgCommon.PubSearchPeriod > 0)
            {
                Interlocked.Exchange(ref pubSearchCounter, this._cfgCommon.PubSearchPeriod);
                if (!ResetTimers.PublicSearch)
                    refreshTasks.Add(this.GetPublicSearchAllAsync());
                ResetTimers.PublicSearch = false;
            }
            if (ResetTimers.UserTimeline || userTimelineCounter <= 0 && this._cfgCommon.UserTimelinePeriod > 0)
            {
                Interlocked.Exchange(ref userTimelineCounter, this._cfgCommon.UserTimelinePeriod);
                if (!ResetTimers.UserTimeline)
                    refreshTasks.Add(this.GetUserTimelineAllAsync());
                ResetTimers.UserTimeline = false;
            }
            if (ResetTimers.Lists || listsCounter <= 0 && this._cfgCommon.ListsPeriod > 0)
            {
                Interlocked.Exchange(ref listsCounter, this._cfgCommon.ListsPeriod);
                if (!ResetTimers.Lists)
                    refreshTasks.Add(this.GetListTimelineAllAsync());
                ResetTimers.Lists = false;
            }
            if (ResetTimers.UserStream || usCounter <= 0 && this._cfgCommon.UserstreamPeriod > 0)
            {
                Interlocked.Exchange(ref usCounter, this._cfgCommon.UserstreamPeriod);
                if (this.tw.UserStreamActive)
                    this.RefreshTimeline();
                ResetTimers.UserStream = false;
            }
            if (refreshFollowers > 6 * 3600)
            {
                Interlocked.Exchange(ref refreshFollowers, 0);
                refreshTasks.AddRange(new[]
                {
                    this.doGetFollowersMenu(),
                    this.RefreshNoRetweetIdsAsync(),
                    this.RefreshTwitterConfigurationAsync(),
                });
            }
            if (osResumed)
            {
                Interlocked.Increment(ref ResumeWait);
                if (ResumeWait > 30)
                {
                    osResumed = false;
                    Interlocked.Exchange(ref ResumeWait, 0);
                    refreshTasks.AddRange(new[]
                    {
                        this.GetHomeTimelineAsync(),
                        this.GetReplyAsync(),
                        this.GetDirectMessagesAsync(),
                        this.GetPublicSearchAllAsync(),
                        this.GetUserTimelineAllAsync(),
                        this.GetListTimelineAllAsync(),
                        this.doGetFollowersMenu(),
                        this.RefreshTwitterConfigurationAsync(),
                    });
                }
            }

            await Task.WhenAll(refreshTasks);
        }
TweenMain