Table of Contents

Class ContentManagerAsyncExtensions

Namespace
Stride.Engine
Assembly
Stride.Engine.dll

Async Load/Reload helpers for ContentManager that propagate the calling MicroThread's synchronization context onto the task — required for code paths that rely on MicroThreadLocal values (e.g. selecting the active database).

public static class ContentManagerAsyncExtensions
Inheritance
object
ContentManagerAsyncExtensions

Methods

LoadAsync(ContentManager, Type, string, ContentManagerLoaderSettings?)

Loads an asset from the specified URL asynchronously.

public static Task<object> LoadAsync(this ContentManager contentManager, Type type, string url, ContentManagerLoaderSettings? settings = null)

Parameters

contentManager ContentManager

The content manager.

type Type

The type.

url string

The URL.

settings ContentManagerLoaderSettings

The settings.

Returns

Task<object>

The loaded content.

Remarks

If the asset is already loaded, it just increases the reference count of the asset and return the same instance.

LoadAsync<T>(IContentManager, UrlReference<T>, ContentManagerLoaderSettings?)

Loads content from the specified UrlReference<T> asynchronously.

public static Task<T> LoadAsync<T>(this IContentManager content, UrlReference<T> urlReference, ContentManagerLoaderSettings? settings = null) where T : class

Parameters

content IContentManager

The IContentManager.

urlReference UrlReference<T>

The URL to load from.

settings ContentManagerLoaderSettings

The settings. If null, fallback to Default.

Returns

Task<T>

The loaded content.

Type Parameters

T

The content type.

Exceptions

ArgumentNullException

If urlReference is null or empty. Or content is null.

LoadAsync<T>(IContentManager, string, ContentManagerLoaderSettings?)

Loads an asset from the specified URL asynchronously.

public static Task<T> LoadAsync<T>(this IContentManager contentManager, string url, ContentManagerLoaderSettings? settings = null) where T : class

Parameters

contentManager IContentManager

The content manager.

url string

The URL to load from.

settings ContentManagerLoaderSettings

The settings. If null, fallback to Default.

Returns

Task<T>

The loaded content.

Type Parameters

T

The content type.

Remarks

If the asset is already loaded, it just increases the reference count of the asset and return the same instance.

ReloadAsync(ContentManager, object, string?, ContentManagerLoaderSettings?)

Reloads a previously loaded asset asynchronously.

public static Task<bool> ReloadAsync(this ContentManager contentManager, object obj, string? newUrl = null, ContentManagerLoaderSettings? settings = null)

Parameters

contentManager ContentManager

The content manager.

obj object

The object to reload.

newUrl string

The url of the new object to load. This allows to replace an asset by another one, or to handle renamed content.

settings ContentManagerLoaderSettings

The loader settings.

Returns

Task<bool>

A task that completes when the content has been reloaded. The result of the task is True if it could be reloaded, false otherwise.

Exceptions

InvalidOperationException

Content not loaded through this ContentManager.