Nez.Portable/Utils/NezContentManager.cs
/// <summary>
/// loads an asset on a background thread with optional callback for when it is loaded. The callback will occur on the main thread.
/// </summary>
/// <param name="assetName">Asset name.</param>
/// <param name="onLoaded">On loaded.</param>
/// <typeparam name="T">The 1st type parameter.</typeparam>
loads an asset on a background thread with optional callback for when it is loaded. The callback will occur on the main thread.
loads an asset on a background thread with optional callback for when it is loaded . The callback will occur on the main thread .
public void loadAsync<T>(string assetName, Action<T> onLoaded = null)
        {
            var syncContext = SynchronizationContext.Current;
            Task.Run(
                () =>
                    {
                        var asset = Load<T>(assetName);
                        if (onLoaded != null)
                        {
                            syncContext.Post(d => { onLoaded(asset); }, null);
                        }
                    });
        }
public void loadAsync < T > ( string assetName , Action < T > onLoaded = null ) { var syncContext = SynchronizationContext . Current ; Task . Run ( ( ) => { var asset = Load < T > ( assetName ) ; if ( onLoaded != null ) { syncContext . Post ( d => { onLoaded ( asset ) ; } , null ) ; } } ) ; }
loads an asset on a background thread with optional callback for when it is loaded.
loads an asset on a background thread with optional callback for when it is loaded .
// if we have a callback do it on the main thread
assetName
string
None
onLoaded
Action<T>
None
typeparam
The 1st type parameter.
The 1st type parameter .