C# Warten Sie auf die Anwendung und warten Sie, bis Finshed Async/Aufgabe istC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 C# Warten Sie auf die Anwendung und warten Sie, bis Finshed Async/Aufgabe ist

Post by Anonymous »

Zuerst bin ich am Anfang des Lernens C#. Seien Sie also bitte sanft :) < /p>
Ich habe eine kleine Windows -Formulations -App, die am Ende einen SteamApp ist. Ich möchte, dass meine App wartet, bis das Spiel gefunden wird und wenn es geschlossen ist, weitere Sachen zu machen.void LaunchViaSteam()
{
try
{
Process.Start(new ProcessStartInfo
{
FileName = "steam://rungameid/1086940",
UseShellExecute = true,
});
}
catch (Exception ex)
{
MessageBox.Show("An error occurred: " + ex.Message);
}
}
< /code>
Ich habe schon so etwas ausprobiert: < /p>
private async void buttonStart_Click(object sender, EventArgs e)
{
Process process = new Process();
process.StartInfo.FileName = SteamDetection.GetSteamDirectory() + "\\steam.exe";
process.StartInfo.Arguments = "steam://rungameid/xxxxxx";
process.Start();
await process.WaitForExitAsync();
}
< /code>
Aber es funktioniert "nicht wie erwartet". Manchmal wartet es einfach nicht oder es wartet darauf, dass Dampf schließt.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post