Quantcast
Channel: Latest Questions by Chesley
Viewing all articles
Browse latest Browse all 62

StreamReader in while loop stops/freezes unity

$
0
0
i am trying to make a script that checks if theres incoming data, using a while loop. but when i use the StreamWriter it waits until it receives data before continuing. is there a way to let this run in the background instead of it blocking unity from rendering the game until it has received the data? i had to Force quit unity for like 20 times since now, and I'm trying to find a solution Current script: void Read() { while(connection.Connected) { try { NetworkStream STREAM = connection.GetStream(); StreamReader IN = new StreamReader(STREAM); string returndata = IN.ReadLine(); string[] returndata2 = returndata.Split(" "[0]); string code = returndata2[0]; string text = returndata.Replace(code, ""); if(code == "#ChatMessage") { BroadcastMessage("AddChatMessage", text); } } catch (Exception c) { } } }

Viewing all articles
Browse latest Browse all 62

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>