Skip to content
This repository was archived by the owner on Nov 28, 2019. It is now read-only.
This repository was archived by the owner on Nov 28, 2019. It is now read-only.

BUG. Hits queue isn't clearing in DispatchAsync(). #31

@23W

Description

@23W

If TrackerManager.DispatchPeriod is set in non zero value, for example 10 seconds, then all hits that were collected from application startup time will be sent every 10 seconds. This is because DispatchAsync() method doesn't clear hits queue for hits that are sent.
Current method's code should be changed to :

        public async Task DispatchAsync()
        {
            if (!isEnabled) return;

            Task allDispatchingTasks = null;
            lock (dispatchingTasks)
            {
                if (dispatchingTasks.Any())
                {
                    allDispatchingTasks = Task.WhenAll(dispatchingTasks);
                }
            }
            if (allDispatchingTasks != null)
            {
                await allDispatchingTasks;
            }

            if (!isEnabled) return;

            Hit[] hitsToSend;
            lock (hits)
            {
                hitsToSend = hits.ToArray();
                hits.Clear(); // clear queue.
            }
            if (hitsToSend.Any())
            {
                await RunDispatchingTask(DispatchQueuedHits(hitsToSend));
            }
        }

Please, fix library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions