Created
March 9, 2021 10:50
-
-
Save olegmrzv/7758372650518402fce5e71e1dce1f98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using UnityEngine; | |
public class NewBehaviourScript : MonoBehaviour | |
{ | |
async void Start() { | |
Debug.Log($"Hi 1 From MainThread {Thread.CurrentThread.ManagedThreadId}"); | |
await Task.Run(async () => { | |
Debug.Log($"Hi 1 From ThreadPool {Thread.CurrentThread.ManagedThreadId}"); | |
await Task.Delay(TimeSpan.FromMilliseconds(500)); | |
Debug.Log($"Hi 2 From ThreadPool {Thread.CurrentThread.ManagedThreadId}"); | |
}).ContinueWith(_ => Debug.Log($"Hi 2 From MainThread {Thread.CurrentThread.ManagedThreadId}"), TaskScheduler.FromCurrentSynchronizationContext()); | |
Debug.Log($"Hi 3 From MainThread {Thread.CurrentThread.ManagedThreadId}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment