modify cannot await twice message
parent
ff15e00003
commit
8a56838111
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
|||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
|
@ -243,8 +244,39 @@ public class SandboxMain : MonoBehaviour
|
|||
public int MyProperty { get; set; }
|
||||
}
|
||||
|
||||
async Task Test1()
|
||||
{
|
||||
var r = await TcsAsync("https://bing.com/");
|
||||
Debug.Log("TASKASYNC");
|
||||
}
|
||||
|
||||
void Start()
|
||||
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()
|
||||
{
|
||||
//UniTaskAsyncEnumerable.EveryValueChanged(mcc, x => x.MyProperty)
|
||||
// .Do(_ => { }, () => Debug.Log("COMPLETED"))
|
||||
|
@ -254,6 +286,9 @@ public class SandboxMain : MonoBehaviour
|
|||
// })
|
||||
// .Forget();
|
||||
|
||||
_ = Test1();
|
||||
Test2().Forget();
|
||||
StartCoroutine(Test3("https://bing.com/"));
|
||||
|
||||
|
||||
// DG.Tweening.Core.TweenerCore<int>
|
||||
|
|
Loading…
Reference in New Issue