LoginSignup
0
1

More than 3 years have passed since last update.

【C#】Task

Posted at

Task

単に「仕事」を意味する動作を指す。

同期型メソッドと非同期型メソッド

まず、同期型メソッドは1から順にTaskを実行するメソッド。
それに対して、非同期型は順序問わず、Taskを実行するメソッドを言う。

★非同期型メソッドのキーワード

async修飾子
 メソッド内でawait演算子を利用するための修飾子。

sample.cs
private async void Click_Action(object sender, RoutedEventArgs e)
{
    // 処理を記述   
}

await演算子
async修飾子が付いているメソッド内で1以上記述できる。
逆を言えばasync修飾子内に1つ以上のawait演算子が必要となる。

Sample.cs
private async void Click_Action(object sender, RoutedEventArgs e)
{
    this.botton.IsEnabled = flase;
    await MouseActionMethod(); // 何かしらの処理を呼び出し
    this.botton.IsEnabled = true;
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1