Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
grantwinney committed Dec 23, 2023
1 parent 862ade9 commit c07a43f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void btnExample2_Click(object sender, EventArgs e)

Task.Run(() => ImportantStuffAsync(progress));

// OOPS! The panel will be re-enabled before the thread completes
// OOPS! The panel will be re-enabled before the Task completes
pnlButtons.Enabled = true;
}

Expand All @@ -71,7 +71,7 @@ private void btnExample4_Click(object sender, EventArgs e)
pnlButtons.Enabled = false;

var result = Task.Run(() => ImportantStuffAsync(progress)).Result;
lblReturnValue.Text = result;
lblReturnValue.Text = $"{result} Control continues on Thread {Environment.CurrentManagedThreadId}.";

pnlButtons.Enabled = true;
}
Expand All @@ -85,7 +85,7 @@ private async void btnExample5_Click(object sender, EventArgs e)

var result = await ImportantStuffAsync(progress);

lblReturnValue.Text = result;
lblReturnValue.Text = $"{result} Control continues on Thread {Environment.CurrentManagedThreadId}.";
pnlButtons.Enabled = true;
}

Expand All @@ -106,7 +106,7 @@ public async Task<string> ImportantStuffAsync(IProgress<int> progress)
await Task.Delay(1000);
progress.Report(3);

return $"Done! ({DateTime.Now:G})";
return $"({DateTime.Now:G}) Task done running on Thread {Environment.CurrentManagedThreadId}.";
}
}
}

0 comments on commit c07a43f

Please sign in to comment.