async public void OnButtonClick4()
{
Debug.LogFormat("ID {0}", Thread.CurrentThread.ManagedThreadId);
{
Debug.Log("OnButtonClick4-1 Init ");
var cancelTokenSource = new CancellationTokenSource();
var aa = Task.Run(Test4Async);
Debug.Log("OnButtonClick4-1 End");
}
{
Debug.Log("OnButtonClick4-2 Init ");
var cancelTokenSource = new CancellationTokenSource();
var aa = Task.Run(Test4Async);
Debug.Log("OnButtonClick4-2 start");
aa.Wait();
Debug.Log("OnButtonClick4-2 End");
}
Debug.Log("END");
}
async Task<int> Test4Async()
{
Debug.LogFormat("Test4Async Start {0}", Thread.CurrentThread.ManagedThreadId);
test_i++;
for (int i = 0; i < counter; i++)
for (int j = 0; j < counter; j++) ;
await Task.Delay(1);
Debug.LogFormat("Test4Async End {0}", Thread.CurrentThread.ManagedThreadId);
return test_i;
}
ID 1
OnButtonClick4-1 Init
OnButtonClick4-1 End
OnButtonClick4-2 Init
OnButtonClick4-2 start
Test4Async Start 458
Test4Async Start 461
Delay
Delay
Test4Async End 432
Test4Async End 453
OnButtonClick4-2 End
END
'Unity > 기타' 카테고리의 다른 글
Dotween (0) | 2019.10.21 |
---|---|
Debug Log 에 칼라 넣기 (0) | 2019.10.11 |
TextMeshProUGUI 에서 한글 폰트 만들기 (0) | 2019.09.18 |
Task를 취소하기 (0) | 2019.09.17 |
쓰레드 풀 & async ask 사용하기 (0) | 2019.09.17 |