Rolf B: Debugging - besonders lange Fehlersuche

Beitrag lesen

Hallo dedlfix,

Warum zum Geier beendet sich das Programm sofort?

Weil die Methode test() async ist und du deshalb mit await drauf warten solltest.

Allerdings... der Compiler frisst weder dies

class Program {
    static void Main(string[] args) {
        test().Wait()
    }

    private static async void test() {
        await Task.Delay(TimeSpan.FromSeconds(5));
    }
}

noch dies (c# 7.1):

class Program {
    static async void Main(string[] args) {
        await test();
    }

    private static async void test() {
        await Task.Delay(TimeSpan.FromSeconds(5));
    }
}

ja ei verbibscht - da muss wohl noch ein dritter nach dem Fehler suchen 😉

Rolf

--
sumpsi - posui - clusi