Task.Delay vs Invoke when restarting level

What would the advantages/disadvantages be between using Task.Delay vs Invoke. For example,

await Task.Delay(TimeSpan.FromSeconds(restartLevelDelayInSeconds))
                .ContinueWith( _=> ReloadLevel(), TaskScheduler.FromCurrentSynchronizationContext());

vs

Invoke(nameof(ReloadLevel),  restartLevelDelayInSeconds));

In the past, Unity did not play well with async/await. I know that it has gotten better, but I have no idea how much. I have personally just stayed away from async/await in Unity. So, I have just made a post that doesn’t answer your question. Sorry.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms