-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathAwaitDataWrap.cs
More file actions
34 lines (31 loc) · 909 Bytes
/
AwaitDataWrap.cs
File metadata and controls
34 lines (31 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Threading.Tasks;
using GameFramework;
namespace UGFExtensions.Await
{
/// <summary>
/// Await包装类
/// </summary>
public class AwaitDataWrap<T> : IReference
{
/// <summary>
/// 自定义数据
/// </summary>
public object UserData { get; private set; }
/// <summary>
/// TaskCompletionSource
/// </summary>
public TaskCompletionSource<T> Source { get; private set; }
public static AwaitDataWrap<T> Create(object userData, TaskCompletionSource<T> source)
{
AwaitDataWrap<T> awaitDataWrap = ReferencePool.Acquire<AwaitDataWrap<T>>();
awaitDataWrap.UserData = userData;
awaitDataWrap.Source = source;
return awaitDataWrap;
}
public void Clear()
{
UserData = null;
Source = null;
}
}
}