This commit is contained in:
ousttrue
2021-02-25 13:07:37 +09:00
parent bf480a600d
commit 3f64a93457
2 changed files with 19 additions and 5 deletions

View File

@@ -78,15 +78,17 @@ namespace UniGLTF.AltTask
public Awaitable(Task task)
{
if (task.IsFaulted)
{
throw task.Exception;
}
_task = task;
if (_task.Exception != null)
{
throw _task.Exception;
}
}
public bool IsCompleted => _task.IsCompleted;
public Exception Exception => _task.Exception;
public IAwaiter GetAwaiter()
{
return new Awaiter(this);
@@ -130,6 +132,10 @@ namespace UniGLTF.AltTask
public void GetResult()
{
if (m_task.Exception != null)
{
throw m_task.Exception;
}
}
public void OnCompleted(Action continuation)

View File

@@ -70,11 +70,15 @@ namespace UniGLTF.AltTask
public Awaitable(Task<T> task)
{
_task = task;
if (_task.Exception != null)
{
throw _task.Exception;
}
}
public bool IsCompleted => _task.IsCompleted;
public T Result => _task.Result;
public Exception Exception => _task.Exception;
public IAwaiter<T> GetAwaiter()
{
@@ -110,6 +114,10 @@ namespace UniGLTF.AltTask
public T GetResult()
{
if (m_task.Exception != null)
{
throw m_task.Exception;
}
return m_task.Result;
}