Session reload stuff

Better async invoke calls for the game thread
This commit is contained in:
Westin Miller
2017-12-03 22:27:30 -08:00
parent 22bd56652d
commit 5b098c68aa
4 changed files with 164 additions and 51 deletions

View File

@@ -74,15 +74,23 @@ namespace Torch.API
/// <summary>
/// Invoke an action on the game thread and block until it has completed.
/// If this is called on the game thread the action will execute immediately.
/// </summary>
void InvokeBlocking(Action action, [CallerMemberName] string caller = "");
/// <param name="action">Action to execute</param>
/// <param name="caller">Caller of the invoke function</param>
/// <param name="timeoutMs">Timeout before <see cref="TimeoutException"/> is thrown, or -1 to never timeout</param>
/// <exception cref="TimeoutException">If the action times out</exception>
void InvokeBlocking(Action action, int timeoutMs = -1, [CallerMemberName] string caller = "");
/// <summary>
/// Invoke an action on the game thread asynchronously.
/// </summary>
Task InvokeAsync(Action action, [CallerMemberName] string caller = "");
/// <summary>
/// Invoke a function on the game thread asynchronously.
/// </summary>
Task<T> InvokeAsync<T>(Func<T> func, [CallerMemberName] string caller = "");
/// <summary>
/// Signals the torch instance to start, then blocks until it's started.
/// </summary>