modify cannot await twice message

pull/61/head
neuecc 2020-05-25 01:55:35 +09:00
parent ff15e00003
commit 8a56838111
4 changed files with 44 additions and 7 deletions

View File

@ -6,6 +6,7 @@ using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.Networking;
public static class EditorRunnerChecker
{
@ -17,11 +18,12 @@ public static class EditorRunnerChecker
static async UniTaskVoid RunCore()
{
Debug.Log("Start, Wait 5 seconds. deltaTime?" + Time.deltaTime);
Debug.Log("Start");
await UniTask.Delay(TimeSpan.FromSeconds(5));
var r = await UnityWebRequest.Get("https://bing.com/").SendWebRequest().ToUniTask();
Debug.Log(r.downloadHandler.text.Substring(0, 100));
Debug.Log("End, Wait 5 seconds. deltaTime?" + Time.deltaTime);
Debug.Log("End");
}
}

View File

@ -26,7 +26,7 @@ namespace Cysharp.Threading.Tasks.CompilerServices
MoveNextRunner()
{
callMoveNext = MoveNext;
callMoveNext = Run;
}
public static MoveNextRunner<TStateMachine> Create(ref TStateMachine stateMachine)
@ -38,7 +38,7 @@ namespace Cysharp.Threading.Tasks.CompilerServices
[DebuggerHidden]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void MoveNext()
void Run()
{
stateMachine.MoveNext();
}

View File

@ -271,7 +271,7 @@ namespace Cysharp.Threading.Tasks
{
if (token != version)
{
throw new InvalidOperationException("token version is not matched, can not await twice.");
throw new InvalidOperationException("Token version is not matched, can not await twice or get Status after await.");
}
}
}

View File

@ -10,6 +10,7 @@ using System.Threading.Tasks;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
@ -243,6 +244,37 @@ public class SandboxMain : MonoBehaviour
public int MyProperty { get; set; }
}
async Task Test1()
{
var r = await TcsAsync("https://bing.com/");
Debug.Log("TASKASYNC");
}
async UniTaskVoid Test2()
{
var r = await UniAsync("https://bing.com/");
Debug.Log("UNIASYNC");
}
IEnumerator Test3(string url)
{
var req = UnityWebRequest.Get(url).SendWebRequest();
yield return req;
Debug.Log("COROUTINE");
}
static async Task<UnityWebRequest> TcsAsync(string url)
{
var req = await UnityWebRequest.Get(url).SendWebRequest();
return req;
}
static async UniTask<UnityWebRequest> UniAsync(string url)
{
var req = await UnityWebRequest.Get(url).SendWebRequest();
return req;
}
void Start()
{
@ -254,6 +286,9 @@ public class SandboxMain : MonoBehaviour
// })
// .Forget();
_ = Test1();
Test2().Forget();
StartCoroutine(Test3("https://bing.com/"));
// DG.Tweening.Core.TweenerCore<int>