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

Commit

Permalink
Update TaskExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
uurha committed Feb 18, 2024
1 parent 06a3e39 commit 26058bb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;

namespace Better.Extensions.Runtime.TasksExtension
{
Expand Down Expand Up @@ -44,6 +46,11 @@ public static async Task WaitUntil(Func<bool> condition, int frequency = 25, int
throw new TimeoutException();
}

public static async void Forget(this Task task)
{
await task;
}

/// <summary>
/// Creates task with factory method
/// </summary>
Expand All @@ -59,5 +66,26 @@ 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);
}

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);
}
}
}
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.1.99",
"version": "1.2.0",
"unity": "2020.1",
"author": {
"name": "Better Plugins",
Expand Down

0 comments on commit 26058bb

Please sign in to comment.