async Task GetMessageAsync() { while (true) { await Task.Delay(500); string x = await Task.Run(() => { while (true) { if (SocketFunctions.RecieveInt(socket) == 0) { break; } } return(SocketFunctions.RecieveString(socket)); }); string[] msg = x.Split(new[] { "%&%" }, StringSplitOptions.None); AllMessages.AppendText(msg[0] + " : " + msg[1] + " " + Environment.NewLine); } }