private async void ListenButton_Click(object sender, RoutedEventArgs e) { if (listenState == listeningStates.notListening) { string serverPort = GetServerPort(); bool result = await Task <bool> .Factory.StartNew(() => { return(commModule.SetupTransport(null, serverPort)); }); Diag.DebugPrint("CommModule setup result: " + result); if (result == true) { ListenButton.Content = "Stop Listening"; listenState = listeningStates.listening; } else { ListenButton.Content = "failed to listen. click to retry"; listenState = listeningStates.notListening; } } else { await ResetTransportTaskAsync(); listenState = listeningStates.notListening; ListenButton.Content = "Listen"; } }
private async void ListenButton_Click(object sender, RoutedEventArgs e) { if (listenState == listeningStates.notListening) { string serverPort = GetServerPort(); bool result = await Task<bool>.Factory.StartNew(() => { return commModule.SetupTransport(null, serverPort); }); Diag.DebugPrint("CommModule setup result: " + result); if (result == true) { ListenButton.Content = "Stop Listening"; listenState = listeningStates.listening; } else { ListenButton.Content = "failed to listen. click to retry"; listenState = listeningStates.notListening; } } else { await ResetTransportTaskAsync(); listenState = listeningStates.notListening; ListenButton.Content = "Listen"; } }