yaro
yaro
CC#
Created by yaro on 8/17/2023 in #help
✅ #async #Unity how to do something after tasks were complete and not block main threads with tasks
i have tasks that can take very log time to complete in unity and at the moment i launch tasks this way async void StartCuttingObjects() { foreach (var g in objectsToCut) { //i have removed some irrelevant code and if you wanna remove parameters in response it is fine var t = Task.Run(() => Cutter.AsyncCut(cutPlane, originalPos, originalRot, originalScale, mf, mr, mesh , subMeshCount, triangles, vertices, normals, uv, mats, g )); tasks.Add(t); } FooAsync(); } public async void FooAsync() { await Task.WhenAll(tasks); EndCuttingObjects(); }
110 replies