public async void xcomMessage(string message, string name) { try { foreach (Soldier soldier in MainWindow.custdata) { if (name == soldier.LastName) { if (soldier.AllowedtoSpeak) { XCOMTcpClient XTC = new XCOMTcpClient( message ); soldier.AllowedtoSpeak = false; //Thread t = new Thread(new ThreadStart(XTC.send_message_to_XCOM_Thread)); //string task = await Task.FromResult<string>(XTC.send_message_to_XCOM_Thread); string returnMessage = await Task <string> .Run(() => XTC.send_message_to_XCOM_Thread()); await Task.Run(() => SoldierMessageTimer(name)); Debug.WriteLine(returnMessage); } } } } catch (NullReferenceException e) { } }
public async void xcomMessage(string message) { XCOMTcpClient XTC = new XCOMTcpClient( message ); //Thread t = new Thread(new ThreadStart(XTC.send_message_to_XCOM_Thread)); //string task = await Task.FromResult<string>(XTC.send_message_to_XCOM_Thread); string returnMessage = await Task <string> .Run(() => XTC.send_message_to_XCOM_Thread()); Debug.WriteLine(returnMessage); if (message == "getSoldierNames") { populateSoldierGrid(returnMessage); } }