게임 설치 중에는 두 종류의 이벤트가 발생됩니다.
이벤트 처리기를 등록하는 방법은 두 가지가 있습니다.
var launcher = new MinecraftLauncher();
await launcher.InstallAsync(
"1.20.4",
new Progress<InstallerProgressChangedEventArgs>(e =>
{
Console.WriteLine("Name: " + e.Name);
Console.WriteLine("EventType: " + e.EventType);
Console.WriteLine("TotalTasks: " + e.TotalTasks);
Console.WriteLine("ProgressedTasks: " + e.ProgressedTasks);
}),
new Progress<ByteProgress>(e =>
{
Console.WriteLine("TotalBytes: " + e.TotalBytes);
Console.WriteLine("ProgressedBytes: " + e.ProgressedBytes);
Console.WriteLine("Percentage: " + e.ToRatio() * 100);
}),
CancellationToken.None);
var launcher = new MinecraftLauncher();
launcher.FileProgressChanged += (_, e) =>
{
Console.WriteLine("Name: " + e.Name);
Console.WriteLine("EventType: " + e.EventType);
Console.WriteLine("TotalTasks: " + e.TotalTasks);
Console.WriteLine("ProgressedTasks: " + e.ProgressedTasks);
};
launcher.ByteProgressChanged += (_, e) =>
{
Console.WriteLine("TotalBytes: " + e.TotalBytes);
Console.WriteLine("ProgressedBytes: " + e.ProgressedBytes);
Console.WriteLine("Percentage: " + e.ToRatio() * 100);
};
await launcher.InstallAsync("1.20.4", CancellationToken.None);