<commit_before>// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE

using System.Threading.Tasks;
using osu.Framework.Allocation;

namespace osu.Framework.Graphics.Containers
{
    /// <summary>
    /// A container which asynchronously loads its children.
    /// </summary>
    public class AsyncLoadContainer : Container
    {
        protected override Container<Drawable> Content => content;

        private readonly Container content = new Container { RelativeSizeAxes = Axes.Both };

        private Game game;

        protected virtual bool ShouldLoadContent => true;

        [BackgroundDependencyLoader]
        private void load(Game game)
        {
            this.game = game;
            if (ShouldLoadContent)
                loadContentAsync();
        }

        protected override void Update()
        {
            base.Update();

            if (!LoadTriggered && ShouldLoadContent)
                loadContentAsync();
        }

        private Task loadTask;

        private void loadContentAsync()
        {
            loadTask = content.LoadAsync(game, d =>
            {
                AddInternal(d);
                d.FadeInFromZero(150);
            });
        }

        protected bool LoadTriggered => loadTask != null;
    }
}<commit_msg>Add callback function.<commit_after>// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE

using System;
using System.Threading.Tasks;
using osu.Framework.Allocation;

namespace osu.Framework.Graphics.Containers
{
    /// <summary>
    /// A container which asynchronously loads its children.
    /// </summary>
    public class AsyncLoadContainer : Container
    {
        /// <summary>
        /// Called when async loading of children has completed.
        /// </summary>
        public Action FinishedLoading;

        protected override Container<Drawable> Content => content;

        private readonly Container content = new Container { RelativeSizeAxes = Axes.Both };

        private Game game;

        protected virtual bool ShouldLoadContent => true;

        [BackgroundDependencyLoader]
        private void load(Game game)
        {
            this.game = game;
            if (ShouldLoadContent)
                loadContentAsync();
        }

        protected override void Update()
        {
            base.Update();

            if (!LoadTriggered && ShouldLoadContent)
                loadContentAsync();
        }

        private Task loadTask;

        private void loadContentAsync()
        {
            loadTask = content.LoadAsync(game, d =>
            {
                AddInternal(d);
                d.FadeInFromZero(150);
                FinishedLoading?.Invoke();
            });
        }

        protected bool LoadTriggered => loadTask != null;
    }
}
{'fraction_non_alphanumeric': 0.09326599326599326, 'fraction_numerical': 0.007407407407407408, 'mean_word_length': 1.9127450980392158, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4226197', 'n_tokens_mistral': 770, 'n_tokens_neox': 721, 'n_words': 196}