Skip to content

Commit

Permalink
add some short async examples
Browse files Browse the repository at this point in the history
  • Loading branch information
grantwinney committed Oct 7, 2024
1 parent 4f3e654 commit 4b98c55
Show file tree
Hide file tree
Showing 9 changed files with 884 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ _(p.s. I have other repos for [C# / .NET code](https://github.com/grantwinney/CS

## Threading

* Async, CancellationToken, and IProgress in 5 Short Examples ([blog post](https://grantwinney.com/async-in-5-short-examples), [source code](https://github.com/grantwinney/SurvivingWinForms/tree/master/Threading/SimpleAsyncExamples))
* Calling an async method from a synchronous one ([blog post](https://grantwinney.com/call-an-async-method-from-a-synchronous-one), [source code](https://github.com/grantwinney/SurvivingWinForms/tree/master/Threading/CallingAsyncMethodFromSynchronousCode))
* Turning a BackgroundWorker into a Task with TaskCompletionSource ([blog post](https://grantwinney.com/turning-a-backgroundworker-into-a-task-with-taskcompletionsource), [source code](https://github.com/grantwinney/SurvivingWinForms/tree/master/Threading/TaskCompletion))
* Using Async, Await, and Task to keep the WinForms UI responsive ([blog post](https://grantwinney.com/using-async-await-and-task-to-keep-the-winforms-ui-more-responsive), [source code](https://github.com/grantwinney/SurvivingWinForms/tree/master/Threading/AsyncAwait))
Expand Down
4 changes: 2 additions & 2 deletions Threading/AsyncAwait/AsyncAwait/frmResponsiveModal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private async void btnMultipleThreads_Click(object sender, EventArgs e)
prgMultipleThreads.Show();

var progress = new Progress<string>();
progress.ProgressChanged += (s, message) =>
progress.ProgressChanged += (_, message) =>
{
if (!txtMultipleThreads.IsDisposed)
txtMultipleThreads.AppendText(message + Environment.NewLine);
Expand All @@ -83,7 +83,7 @@ private async void btnMultipleThreadsHeavy_Click(object sender, EventArgs e)
prgMultipleThreadsHeavy.Show();

var progress = new Progress<string>();
progress.ProgressChanged += (s, message) =>
progress.ProgressChanged += (_, message) =>
{
if (!txtMultipleThreadsHeavy.IsDisposed)
txtMultipleThreadsHeavy.AppendText(message + Environment.NewLine);
Expand Down
25 changes: 25 additions & 0 deletions Threading/SimpleAsyncExamples/SimpleAsyncExamples.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35303.130
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleAsyncExamples", "SimpleAsyncExamples\SimpleAsyncExamples.csproj", "{DCEBA89D-2623-4376-9BE8-D35591F387B0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DCEBA89D-2623-4376-9BE8-D35591F387B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCEBA89D-2623-4376-9BE8-D35591F387B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCEBA89D-2623-4376-9BE8-D35591F387B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCEBA89D-2623-4376-9BE8-D35591F387B0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2BD652D9-6189-45CB-8C78-E73074D7746B}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 4b98c55

Please sign in to comment.