osu.Framework/Graphics/Containers/CompositeDrawable.cs
/// <summary>
/// Loads several future child or grand-child of this <see cref="CompositeDrawable"/> asynchronously. <see cref="Dependencies"/>
/// and <see cref="Drawable.Clock"/> are inherited from this <see cref="CompositeDrawable"/>.
///
/// Note that this will always use the dependencies and clock from this instance. If you must load to a nested container level,
/// consider using <see cref="DelayedLoadWrapper"/>
/// </summary>
/// <typeparam name="TLoadable">The type of the future future child or grand-child to be loaded.</typeparam>
/// <param name="components">The children or grand-children to be loaded.</param>
/// <param name="onLoaded">Callback to be invoked on the update thread after loading is complete.</param>
/// <param name="cancellation">An optional cancellation token.</param>
/// <param name="scheduler">The scheduler for <paramref name="onLoaded"/> to be invoked on. If null, the local scheduler will be used.</param>
/// <returns>The task which is used for loading and callbacks.</returns>
Loads several future child or grand-child of this  asynchronously.
and  are inherited from this .

Note that this will always use the dependencies and clock from this instance. If you must load to a nested container level,
consider using
Loads several future child or grand - child of this asynchronously . and are inherited from this . Note that this will always use the dependencies and clock from this instance . If you must load to a nested container level consider using
protected internal Task LoadComponentsAsync<TLoadable>(IEnumerable<TLoadable> components, Action<IEnumerable<TLoadable>> onLoaded = null, CancellationToken cancellation = default,
                                                               Scheduler scheduler = null)
            where TLoadable : Drawable
        {
            if (game == null)
                throw new InvalidOperationException($"May not invoke {nameof(LoadComponentAsync)} prior to this {nameof(CompositeDrawable)} being loaded.");
            if (IsDisposed)
                throw new ObjectDisposedException(ToString());
            if (disposalCancellationSource == null)
                disposalCancellationSource = new CancellationTokenSource();
            var linkedSource = CancellationTokenSource.CreateLinkedTokenSource(disposalCancellationSource.Token, cancellation);
            var deps = new DependencyContainer(Dependencies);
            deps.CacheValueAs(linkedSource.Token);
            return Task.Factory.StartNew(() => loadComponents(components, deps), linkedSource.Token, TaskCreationOptions.HideScheduler, threaded_scheduler).ContinueWith(t =>
            {
                var exception = t.Exception?.AsSingular();
                if (linkedSource.Token.IsCancellationRequested)
                {
                    linkedSource.Dispose();
                    return;
                }
                (scheduler ?? Scheduler).Add(() =>
                {
                    try
                    {
                        if (exception != null)
                            throw exception;
                        if (!linkedSource.Token.IsCancellationRequested)
                            onLoaded?.Invoke(components);
                    }
                    finally
                    {
                        linkedSource.Dispose();
                    }
                });
            }, CancellationToken.None);
        }
protected internal Task LoadComponentsAsync < TLoadable > ( IEnumerable < TLoadable > components , Action < IEnumerable < TLoadable > > onLoaded = null , CancellationToken cancellation = default , Scheduler scheduler = null ) where TLoadable : Drawable { if ( game == null ) throw new InvalidOperationException ( $" May not invoke  { nameof ( LoadComponentAsync ) }  prior to this  { nameof ( CompositeDrawable ) }  being loaded. " ) ; if ( IsDisposed ) throw new ObjectDisposedException ( ToString ( ) ) ; if ( disposalCancellationSource == null ) disposalCancellationSource = new CancellationTokenSource ( ) ; var linkedSource = CancellationTokenSource . CreateLinkedTokenSource ( disposalCancellationSource . Token , cancellation ) ; var deps = new DependencyContainer ( Dependencies ) ; deps . CacheValueAs ( linkedSource . Token ) ; return Task . Factory . StartNew ( ( ) => loadComponents ( components , deps ) , linkedSource . Token , TaskCreationOptions . HideScheduler , threaded_scheduler ) . ContinueWith ( t => { var exception = t . Exception ? . AsSingular ( ) ; if ( linkedSource . Token . IsCancellationRequested ) { linkedSource . Dispose ( ) ; return ; } ( scheduler ?? Scheduler ) . Add ( ( ) => { try { if ( exception != null ) throw exception ; if ( ! linkedSource . Token . IsCancellationRequested ) onLoaded ? . Invoke ( components ) ; } finally { linkedSource . Dispose ( ) ; } } ) ; } , CancellationToken . None ) ; }
Loads several future child or grand-child of this  asynchronously.
Loads several future child or grand - child of this asynchronously .
The task which is used for loading and callbacks.
The task which is used for loading and callbacks .
components
IEnumerable<TLoadable>
The children or grand-children to be loaded.
The children or grand - children to be loaded .
onLoaded
Action<IEnumerable<TLoadable>>
Callback to be invoked on the update thread after loading is complete.
Callback to be invoked on the update thread after loading is complete .
cancellation
CancellationToken
An optional cancellation token.
An optional cancellation token .
scheduler
Scheduler
The scheduler for  to be invoked on. If null, the local scheduler will be used.
The scheduler for to be invoked on . If null the local scheduler will be used .
typeparam
The type of the future future child or grand-child to be loaded.
The type of the future future child or grand - child to be loaded .