유니티 C# 비동기 프로그래밍 Task 간단 사용법

반응형
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;

public class Example : MonoBehaviour
{
    int number = 0;

    private void Start()
    {
        Task.Run(() => Testing());
    }

    async Task Testing()
    {
        await Task.Run(() =>
        {
            while(number < 500)
            {
                number++;
            }
        });

        await Task.Delay(5000);
    }
}
반응형