fork download
  1. private async void button1_Click(object sender, EventArgs e)
  2. {
  3. this.button1.Enabled = false; // 処理中にボタンを押されないようにボタンを無効にする
  4. this.label1.BackColor = Color.Red; // ラベル背景色変更
  5. this.label1.Text = "実行中";
  6. this.progressBar1.Style = ProgressBarStyle.Marquee; // プログレスバーをマーキー表示に
  7.  
  8.   // 重い処理は別タスクで非同期実行
  9. await Task.Run(() =>
  10. {
  11. //ちょっと時間のかかる処理
  12. Thread.Sleep(10000);
  13. });
  14.  
  15. this.progressBar1.Style = ProgressBarStyle.Continuous; // プログレスバーを止める
  16. this.label1.BackColor = SystemColors.Control; // ラベル背景色を元に戻す
  17. this.label1.Text = string.Empty;
  18. this.button1.Enabled = true; // ボタンを有効に戻す
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,8): error CS1525: Unexpected symbol `async', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty