.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,607 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder.UseMauiApp<App>();
builder.ConfigureFonts(fonts => {
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Light.ttf", "OpenSansLight");
fonts.AddFont("OpenSans-Medium.ttf", "OpenSansMedium");
fonts.AddFont("OpenSans-Bold.ttf", "OpenSansBold");
});
Debug.WriteLine(DateTime.Now + " | Start LoadedUserData");
LoadedUserData();
Debug.WriteLine(DateTime.Now + " | End LoadedUserData");
return builder.Build();
}
static async Task LoadedUserData()
{
await Task.Run(() => Debug.WriteLine(DateTime.Now + " | Run LoadedUserData"));
}
}
Объясните что я делаю не так. У меня в консоль выводится "Start", "End" и "Run"
LoadedUserData() is an asynchronous task. but the caller does delay until it completes, so the next line (a debug print) runs before the LoadedUserData() completes. try:
Debug.WriteLine(DateTime.Now + " | Start LoadedUserData");
LoadedUserData().Wait();
Debug.WriteLine(DateTime.Now + " | End LoadedUserData");