private async void DownloadFile(object sender, RoutedEventArgs e) { //if not connected if (!myConnection.IsConnected) { MessageBox.Show("You are not connected with any server."); } else if (fileToDownload == null) { MessageBox.Show("No file to download."); } else if (myConnection.IsBusy) { MessageBox.Show("Can't download file if server is busy."); } else { ServerStatus(true); await myConnection.GetFile(); ServerStatus(false); } }