how can i make NetworkStream.GetStream a coroutine?
i currently use Threading to avoid the main thread because the NetworkStream.GetStream waits for data before continuing and that temporarily freezes Unity until new data arrives. so i have no idea how to make this a coroutine
I’m doing a whole workaround to get data from my thread to the main thread and that just slows things down
Coroutines are a form of cooperative multithreading that are actually run on the main thread. Since you cannot interrupt NetworkStream.GetStream() it cannot be a coroutine. And you certainly don’t want your network I/O to block the main thread.
Network I/O definitively belongs in a separate worker thread.