Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Create TaskUtility
Browse files Browse the repository at this point in the history
  • Loading branch information
uurha committed Feb 20, 2024
1 parent 26058bb commit 8f618f0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static async void Forget(this Task task)
{
await task;
}

/// <summary>
/// Creates task with factory method
/// </summary>
Expand All @@ -66,7 +66,7 @@ public static Task WhenAll(this IEnumerable<Task> tasks)
{
return Task.WhenAll(tasks);
}

public static Task<T[]> WhenAll<T>(this IEnumerable<Task<T>> tasks)
{
return Task.WhenAll(tasks);
Expand All @@ -76,13 +76,13 @@ public static Task WhenAny(this IEnumerable<Task> tasks)
{
return Task.WhenAny(tasks);
}

public static async Task<T> WhenAny<T>(this IEnumerable<Task<T>> tasks)
{
var task = await Task.WhenAny(tasks);
return await task;
}

public static Task WaitForSeconds(float seconds, CancellationToken cancellationToken = default)
{
return Task.Delay(Mathf.RoundToInt(seconds * 1000), cancellationToken);
Expand Down
3 changes: 3 additions & 0 deletions Assets/BetterExtensions/Runtime/Utility.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Assets/BetterExtensions/Runtime/Utility/TaskUtility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;

namespace Better.Extensions.Runtime.Utility
{
public static class TaskUtility
{
public static Task WaitForSeconds(float seconds, CancellationToken cancellationToken = default)
{
return Task.Delay(Mathf.RoundToInt(seconds * 1000), cancellationToken);
}
}
}
3 changes: 3 additions & 0 deletions Assets/BetterExtensions/Runtime/Utility/TaskUtility.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/BetterExtensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.uurha.betterextensions",
"displayName": "Better Extensions",
"description": "Unity extensions, serialize extension, async extension, string extension and UI extensions",
"version": "1.2.0",
"version": "1.2.1",
"unity": "2020.1",
"author": {
"name": "Better Plugins",
Expand Down

0 comments on commit 8f618f0

Please sign in to comment.