KO CSharp Keyword await - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
ํธ๋๋ถ C# ยท ์ค์ฉ ๊ฐ์ด๋
๋๊ธฐ ๊ฐ๋ฅํ ์์ ์ ๋น๋๊ธฐ์ ์ผ๋ก ๊ธฐ๋ค๋ฆฌ๊ณ ํด๋น ๊ฒฐ๊ณผ๋ฅผ ๋ฐ์ต๋๋ค. ๋๊ธฐํ ๋ ์์ ์ค๋ฅ๊ฐ ๋ํ๋ฉ๋๋ค.
์ด ์์ ๋ฅผ Example.cs๋ก ๋ฐ๋ก ์ ์ฅํ๊ณ ์ด ํ์ด์ง์ ๋ค๋ฅธ ์์ ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ์ธ์.
Example.cs:
// PROJECT-EXAMPLE
await System.Threading.Tasks.Task.Delay(1);
System.Console.WriteLine("Done");๊ฒฐ๊ณผ:
Done
var result = await operation;using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
int result = await Jobs.DoubleAsync(4);
Console.WriteLine(result);
}
}
public static class Jobs { public static async Task<int> DoubleAsync(int value) { await Task.Delay(1); return value * 2; } }using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
Task<int>[] jobs = [Jobs.CountAsync(2), Jobs.CountAsync(3)];
int[] results = await Task.WhenAll(jobs);
Console.WriteLine(results.Sum());
}
}
public static class Jobs { public static async Task<int> CountAsync(int value) { await Task.Yield(); return value; } }๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.