跳轉到內容

C# 程式設計/關鍵字/async

來自華夏公益教科書,開放的書籍,為開放的世界

在非同步程式設計中使用asyncawait 上下文關鍵字。非同步程式設計允許一個程序等待直到一個方法完成並返回一個值(或超時或以其他方式失敗)。async 關鍵字必須用於修改包含 await 表示式或方法的方法或 lambda 表示式。這兩個關鍵字使得非同步程式設計很容易實現。只需在任何可能長時間執行的呼叫前加上 await 關鍵字,例如,var text = await getLargeDataSet(); 並將 async 修飾符新增到包含的方法(或 lambda 表示式)。async 和 await 關鍵字在 JavaScript 和其他語言中可用,並在 C# 版本 5.0 中引入。



C# 關鍵字
abstract as base bool break
byte case catch char checked
class const continue decimal default
delegate do double else enum
event explicit extern false finally
fixed float for foreach goto
if implicit in int interface
internal is lock long namespace
new null object operator out
override params private protected public
readonly ref return sbyte sealed
short sizeof stackalloc static string
struct switch this throw true
try typeof uint ulong unchecked
unsafe ushort using var virtual
void volatile while
C# 特殊識別符號(上下文關鍵字)
add alias async await dynamic
get global nameof partial remove
set value when where yield
上下文關鍵字(在查詢中使用)
ascending by descending equals from
group in into join let
on orderby select where
華夏公益教科書