├── .vs
├── ProjectSettings.json
├── slnx.sqlite
└── VSWorkspaceState.json
├── UnderstandingAsync
├── obj
│ ├── Debug
│ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
│ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
│ │ ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
│ │ ├── MainWindow.baml
│ │ ├── UnderstandingAsync.g.resources
│ │ ├── UnderstandingAsync.Properties.Resources.resources
│ │ ├── App.g.cs
│ │ ├── App.g.i.cs
│ │ ├── UnderstandingAsync.csproj.FileListAbsolute.txt
│ │ ├── MainWindow.g.cs
│ │ └── MainWindow.g.i.cs
│ └── Release
│ │ ├── MainWindow.baml
│ │ ├── App.g.cs
│ │ └── MainWindow.g.cs
├── App.config
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── bin
│ └── Debug
│ │ ├── UnderstandingAsync.exe.config
│ │ ├── UnderstandingAsync.vshost.exe.config
│ │ └── UnderstandingAsync.vshost.exe.manifest
├── App.xaml.cs
├── App.xaml
├── TaskExamples.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
└── UnderstandingAsync.csproj
└── UnderstandingAsync.sln
/.vs/ProjectSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "CurrentProjectSetting": null
3 | }
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.vs/slnx.sqlite:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MichaelPuckett2/AsyncAwait-C-Examples/HEAD/.vs/slnx.sqlite
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/MainWindow.baml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MichaelPuckett2/AsyncAwait-C-Examples/HEAD/UnderstandingAsync/obj/Debug/MainWindow.baml
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Release/MainWindow.baml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MichaelPuckett2/AsyncAwait-C-Examples/HEAD/UnderstandingAsync/obj/Release/MainWindow.baml
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/UnderstandingAsync.g.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MichaelPuckett2/AsyncAwait-C-Examples/HEAD/UnderstandingAsync/obj/Debug/UnderstandingAsync.g.resources
--------------------------------------------------------------------------------
/.vs/VSWorkspaceState.json:
--------------------------------------------------------------------------------
1 | {
2 | "ExpandedNodes": [
3 | "",
4 | "\\UnderstandingAsync"
5 | ],
6 | "SelectedNode": "\\UnderstandingAsync.sln",
7 | "PreviewInSolutionExplorer": false
8 | }
--------------------------------------------------------------------------------
/UnderstandingAsync/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/UnderstandingAsync.Properties.Resources.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MichaelPuckett2/AsyncAwait-C-Examples/HEAD/UnderstandingAsync/obj/Debug/UnderstandingAsync.Properties.Resources.resources
--------------------------------------------------------------------------------
/UnderstandingAsync/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/UnderstandingAsync/bin/Debug/UnderstandingAsync.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/UnderstandingAsync/bin/Debug/UnderstandingAsync.vshost.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/UnderstandingAsync/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace UnderstandingAsync
4 | {
5 | ///
6 | /// Interaction logic for App.xaml
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/UnderstandingAsync/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/UnderstandingAsync/bin/Debug/UnderstandingAsync.vshost.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/UnderstandingAsync.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.20827.3
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnderstandingAsync", "UnderstandingAsync\UnderstandingAsync.csproj", "{7756A991-FE7D-4B82-AD80-DAEB52821DF2}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {7756A991-FE7D-4B82-AD80-DAEB52821DF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {7756A991-FE7D-4B82-AD80-DAEB52821DF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {7756A991-FE7D-4B82-AD80-DAEB52821DF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {7756A991-FE7D-4B82-AD80-DAEB52821DF2}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/UnderstandingAsync/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace UnderstandingAsync.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.1.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/UnderstandingAsync/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("UnderstandingAsync")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("UnderstandingAsync")]
15 | [assembly: AssemblyCopyright("Copyright © 2013")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/App.g.cs:
--------------------------------------------------------------------------------
1 | #pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "9C21C8D45D71F980A43A7CE5A776DE81"
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version:4.0.30319.42000
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | //------------------------------------------------------------------------------
11 |
12 | using System;
13 | using System.Diagnostics;
14 | using System.Windows;
15 | using System.Windows.Automation;
16 | using System.Windows.Controls;
17 | using System.Windows.Controls.Primitives;
18 | using System.Windows.Data;
19 | using System.Windows.Documents;
20 | using System.Windows.Ink;
21 | using System.Windows.Input;
22 | using System.Windows.Markup;
23 | using System.Windows.Media;
24 | using System.Windows.Media.Animation;
25 | using System.Windows.Media.Effects;
26 | using System.Windows.Media.Imaging;
27 | using System.Windows.Media.Media3D;
28 | using System.Windows.Media.TextFormatting;
29 | using System.Windows.Navigation;
30 | using System.Windows.Shapes;
31 | using System.Windows.Shell;
32 |
33 |
34 | namespace UnderstandingAsync {
35 |
36 |
37 | ///
38 | /// App
39 | ///
40 | public partial class App : System.Windows.Application {
41 |
42 | ///
43 | /// InitializeComponent
44 | ///
45 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
46 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
47 | public void InitializeComponent() {
48 |
49 | #line 4 "..\..\App.xaml"
50 | this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
51 |
52 | #line default
53 | #line hidden
54 | }
55 |
56 | ///
57 | /// Application Entry Point.
58 | ///
59 | [System.STAThreadAttribute()]
60 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
61 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
62 | public static void Main() {
63 | UnderstandingAsync.App app = new UnderstandingAsync.App();
64 | app.InitializeComponent();
65 | app.Run();
66 | }
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/App.g.i.cs:
--------------------------------------------------------------------------------
1 | #pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "9C21C8D45D71F980A43A7CE5A776DE81"
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version:4.0.30319.42000
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | //------------------------------------------------------------------------------
11 |
12 | using System;
13 | using System.Diagnostics;
14 | using System.Windows;
15 | using System.Windows.Automation;
16 | using System.Windows.Controls;
17 | using System.Windows.Controls.Primitives;
18 | using System.Windows.Data;
19 | using System.Windows.Documents;
20 | using System.Windows.Ink;
21 | using System.Windows.Input;
22 | using System.Windows.Markup;
23 | using System.Windows.Media;
24 | using System.Windows.Media.Animation;
25 | using System.Windows.Media.Effects;
26 | using System.Windows.Media.Imaging;
27 | using System.Windows.Media.Media3D;
28 | using System.Windows.Media.TextFormatting;
29 | using System.Windows.Navigation;
30 | using System.Windows.Shapes;
31 | using System.Windows.Shell;
32 |
33 |
34 | namespace UnderstandingAsync {
35 |
36 |
37 | ///
38 | /// App
39 | ///
40 | public partial class App : System.Windows.Application {
41 |
42 | ///
43 | /// InitializeComponent
44 | ///
45 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
46 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
47 | public void InitializeComponent() {
48 |
49 | #line 4 "..\..\App.xaml"
50 | this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
51 |
52 | #line default
53 | #line hidden
54 | }
55 |
56 | ///
57 | /// Application Entry Point.
58 | ///
59 | [System.STAThreadAttribute()]
60 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
61 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
62 | public static void Main() {
63 | UnderstandingAsync.App app = new UnderstandingAsync.App();
64 | app.InitializeComponent();
65 | app.Run();
66 | }
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Release/App.g.cs:
--------------------------------------------------------------------------------
1 | #pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "9C21C8D45D71F980A43A7CE5A776DE81"
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version:4.0.30319.42000
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | //------------------------------------------------------------------------------
11 |
12 | using System;
13 | using System.Diagnostics;
14 | using System.Windows;
15 | using System.Windows.Automation;
16 | using System.Windows.Controls;
17 | using System.Windows.Controls.Primitives;
18 | using System.Windows.Data;
19 | using System.Windows.Documents;
20 | using System.Windows.Ink;
21 | using System.Windows.Input;
22 | using System.Windows.Markup;
23 | using System.Windows.Media;
24 | using System.Windows.Media.Animation;
25 | using System.Windows.Media.Effects;
26 | using System.Windows.Media.Imaging;
27 | using System.Windows.Media.Media3D;
28 | using System.Windows.Media.TextFormatting;
29 | using System.Windows.Navigation;
30 | using System.Windows.Shapes;
31 | using System.Windows.Shell;
32 |
33 |
34 | namespace UnderstandingAsync {
35 |
36 |
37 | ///
38 | /// App
39 | ///
40 | public partial class App : System.Windows.Application {
41 |
42 | ///
43 | /// InitializeComponent
44 | ///
45 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
46 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
47 | public void InitializeComponent() {
48 |
49 | #line 4 "..\..\App.xaml"
50 | this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
51 |
52 | #line default
53 | #line hidden
54 | }
55 |
56 | ///
57 | /// Application Entry Point.
58 | ///
59 | [System.STAThreadAttribute()]
60 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
61 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
62 | public static void Main() {
63 | UnderstandingAsync.App app = new UnderstandingAsync.App();
64 | app.InitializeComponent();
65 | app.Run();
66 | }
67 | }
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/UnderstandingAsync/TaskExamples.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 |
4 | namespace UnderstandingAsync
5 | {
6 | static public class TaskExamples
7 | {
8 | static int TaskCounter = 0;
9 | public const int DefaultSleepTime = 3000;
10 | static int sleepTime = DefaultSleepTime;
11 |
12 | static public int SleepTime
13 | {
14 | get => sleepTime; set { sleepTime = value; }
15 | }
16 |
17 | //Task
18 | //This continues on the main thread.
19 | static public Task StringTask() => SubTaskForTask(nameof(StringTask)); //Blocking
20 |
21 | //async Task//This continues on the main thread.
22 | static async public Task AsyncStringTask() => await SubTaskForTask(nameof(AsyncStringTask)); //Blocking
23 |
24 | //Task.Run
25 | //This method actually runs on a background thread where the others are continuations of the main thread.
26 | static public Task StringTaskDotRunAsync() => Task.Run(() => SubTaskForTask(nameof(StringTaskDotRunAsync))); //Non-Blocking
27 |
28 | /*
29 | * This task is broken on purpose.
30 | * Notice that when you call the task it will continue processing on the main thread until for the 1st second.
31 | * Then it will lock the thread for another second.
32 | * This is because the task is running on the same thread that it is called on regardless of async await.
33 | * The only way to get this task to operate without blocking the calling thread (most like the UI / Main thread) is to use Task.Run
34 | * There are 3 wrapper methods above that call this task in various ways to illustrate the difference.
35 | */
36 | static private async Task SubTaskForTask(string taskName)
37 | {
38 | Thread.Sleep(sleepTime / 3); //UI thread
39 | await Task.Delay(sleepTime / 3); //New thread
40 | Thread.Sleep(sleepTime / 3); //UI thread
41 |
42 | return $"Task {++TaskCounter}: {taskName}";
43 | }
44 |
45 |
46 | //This method below isn't used. However; the one above should be replaced with the one below for a proper awaitable task.
47 | //static private Task SubTaskForTaskAsync(string taskName)
48 | //{
49 | // return Task.Run(async () =>
50 | // {
51 | // Thread.Sleep(sleepTime / 3); //UI thread
52 | // await Task.Delay(sleepTime / 3); //New thread
53 | // Thread.Sleep(sleepTime / 3); //UI thread
54 |
55 | // return $"Task {++TaskCounter}: {taskName}";
56 | // });
57 | //}
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/UnderstandingAsync/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace UnderstandingAsync.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UnderstandingAsync.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/UnderstandingAsync.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\Michael Puckett\AppData\Local\Temporary Projects\UnderstandingAsync\bin\Debug\UnderstandingAsync.exe.config
2 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\bin\Debug\UnderstandingAsync.exe.config
3 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\obj\Debug\UnderstandingAsync.csprojResolveAssemblyReference.cache
4 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\obj\Debug\MainWindow.baml
5 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\obj\Debug\MainWindow.g.cs
6 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\obj\Debug\App.g.cs
7 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\obj\Debug\UnderstandingAsync_MarkupCompile.cache
8 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\obj\Debug\UnderstandingAsync.g.resources
9 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\obj\Debug\UnderstandingAsync.Properties.Resources.resources
10 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\obj\Debug\UnderstandingAsync.csproj.GenerateResource.Cache
11 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\bin\Debug\UnderstandingAsync.exe
12 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\bin\Debug\UnderstandingAsync.pdb
13 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\obj\Debug\UnderstandingAsync.exe
14 | C:\Users\Michael Puckett\Documents\Visual Studio 2013\Projects\UnderstandingAsync\UnderstandingAsync\obj\Debug\UnderstandingAsync.pdb
15 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\bin\Debug\UnderstandingAsync.exe.config
16 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\bin\Debug\UnderstandingAsync.exe
17 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\bin\Debug\UnderstandingAsync.pdb
18 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\obj\Debug\UnderstandingAsync.csprojResolveAssemblyReference.cache
19 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\obj\Debug\MainWindow.baml
20 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\obj\Debug\MainWindow.g.cs
21 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\obj\Debug\App.g.cs
22 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\obj\Debug\UnderstandingAsync_MarkupCompile.cache
23 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\obj\Debug\UnderstandingAsync.g.resources
24 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\obj\Debug\UnderstandingAsync.Properties.Resources.resources
25 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\obj\Debug\UnderstandingAsync.csproj.GenerateResource.Cache
26 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\obj\Debug\UnderstandingAsync.exe
27 | C:\Users\micha\Repos\AsyncAwait-C-Examples\UnderstandingAsync\obj\Debug\UnderstandingAsync.pdb
28 |
--------------------------------------------------------------------------------
/UnderstandingAsync/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
24 |
25 |
29 |
30 |
34 |
35 |
39 |
40 |
43 |
45 |
50 |
51 |
53 |
54 |
55 |
58 |
59 |
63 |
64 |
70 |
71 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/UnderstandingAsync/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading.Tasks;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 |
7 | namespace UnderstandingAsync
8 | {
9 | public partial class MainWindow : Window
10 | {
11 | System.Timers.Timer timer = new System.Timers.Timer(10);
12 |
13 | public MainWindow()
14 | {
15 | InitializeComponent();
16 |
17 | TextBox_SleepTime.Text = TaskExamples.SleepTime.ToString();
18 |
19 | initializeTimer();
20 | }
21 |
22 | private void initializeTimer()
23 | {
24 | timer = new System.Timers.Timer(10);
25 |
26 | timer.Elapsed += (s, e) =>
27 | {
28 | DateTime now = DateTime.Now;
29 | Application.Current.Dispatcher.Invoke(() => TextBlock_Timer.Text = $"{now.Second}.{now.Millisecond}");
30 | };
31 |
32 | Loaded += (s, e) => timer.Start();
33 | Closing += (s, e) => timer.Stop();
34 | }
35 |
36 | private async void buttonClick(object sender, RoutedEventArgs e)
37 | {
38 | var button = sender as Button;
39 |
40 | if ((CheckBox_DisableButton.IsChecked).GetValueOrDefault())
41 | button.IsEnabled = false;
42 |
43 | var result = string.Empty;
44 |
45 | switch (button.Name)
46 | {
47 | case nameof(StringTaskButton):
48 | result = await TaskExamples.StringTask();
49 | break;
50 |
51 | case nameof(AsyncStringTaskButton):
52 | result = await TaskExamples.AsyncStringTask();
53 | break;
54 |
55 | case nameof(TaskDotRunButton):
56 | result = await TaskExamples.StringTaskDotRunAsync();
57 | break;
58 |
59 | default:
60 | result = "No Result Found";
61 | break;
62 |
63 | }
64 |
65 | ListBoxResults.Items.Add(result);
66 |
67 | button.IsEnabled = true;
68 | }
69 |
70 | private async void RunAll_Click(object sender, RoutedEventArgs e)
71 | {
72 | var button = sender as Button;
73 |
74 | if (CheckBox_DisableButton.IsChecked.GetValueOrDefault())
75 | button.IsEnabled = false;
76 |
77 | var tasks = new List>()
78 | {
79 | TaskExamples.StringTask(),
80 | TaskExamples.StringTaskDotRunAsync(),
81 | TaskExamples.AsyncStringTask()
82 | };
83 |
84 | //Comment out here and foreach and uncomment tasks.ForEach. The lambda expression gets returned to each call immediately and the ForEach becomes asynchronous.
85 | //The reason is there is no overload of ForEach that will return task such as ForEachAsync; that can be awaited.
86 | await Task.WhenAll(tasks);
87 |
88 | foreach (var task in tasks)
89 | ListBoxResults.Items.Add(task.Result);
90 |
91 | /* The ForEach lambda expression required it's own async / await as shown below.
92 | * If you uncomment the line below and comment out the foreach (var task...) above then you'll notice the button
93 | * is re-enabled before all tasks are complete. Therefore we can see that the ForEach lambda expression is started and returned to this task
94 | * before it completes. Both work but the button is re-enabled before completion. */
95 |
96 | //tasks.ForEach(async task => ListBoxResults.Items.Add(await task));
97 |
98 | button.IsEnabled = true;
99 | }
100 |
101 | private void ClearList_Click(object sender, RoutedEventArgs e)
102 | => ListBoxResults.Items.Clear();
103 |
104 | private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
105 | {
106 | if (int.TryParse(TextBox_SleepTime.Text, out int sleepTime))
107 | TaskExamples.SleepTime = Convert.ToInt32(TextBox_SleepTime.Text);
108 | else
109 | TextBox_SleepTime.Text = TaskExamples.DefaultSleepTime.ToString();
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/UnderstandingAsync/UnderstandingAsync.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {7756A991-FE7D-4B82-AD80-DAEB52821DF2}
8 | WinExe
9 | Properties
10 | UnderstandingAsync
11 | UnderstandingAsync
12 | v4.6.2
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 |
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 | 7
28 |
29 |
30 | AnyCPU
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 4.0
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | MSBuild:Compile
56 | Designer
57 |
58 |
59 |
60 | MSBuild:Compile
61 | Designer
62 |
63 |
64 | App.xaml
65 | Code
66 |
67 |
68 | MainWindow.xaml
69 | Code
70 |
71 |
72 |
73 |
74 | Code
75 |
76 |
77 | True
78 | True
79 | Resources.resx
80 |
81 |
82 | True
83 | Settings.settings
84 | True
85 |
86 |
87 | ResXFileCodeGenerator
88 | Resources.Designer.cs
89 |
90 |
91 | SettingsSingleFileGenerator
92 | Settings.Designer.cs
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
107 |
--------------------------------------------------------------------------------
/UnderstandingAsync/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/MainWindow.g.cs:
--------------------------------------------------------------------------------
1 | #pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "657B25D0977E963ED5C01EE15B101492"
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version:4.0.30319.42000
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | //------------------------------------------------------------------------------
11 |
12 | using System;
13 | using System.Diagnostics;
14 | using System.Windows;
15 | using System.Windows.Automation;
16 | using System.Windows.Controls;
17 | using System.Windows.Controls.Primitives;
18 | using System.Windows.Data;
19 | using System.Windows.Documents;
20 | using System.Windows.Ink;
21 | using System.Windows.Input;
22 | using System.Windows.Markup;
23 | using System.Windows.Media;
24 | using System.Windows.Media.Animation;
25 | using System.Windows.Media.Effects;
26 | using System.Windows.Media.Imaging;
27 | using System.Windows.Media.Media3D;
28 | using System.Windows.Media.TextFormatting;
29 | using System.Windows.Navigation;
30 | using System.Windows.Shapes;
31 | using System.Windows.Shell;
32 |
33 |
34 | namespace UnderstandingAsync {
35 |
36 |
37 | ///
38 | /// MainWindow
39 | ///
40 | public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
41 |
42 |
43 | #line 21 "..\..\MainWindow.xaml"
44 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
45 | internal System.Windows.Controls.Button StringTaskButton;
46 |
47 | #line default
48 | #line hidden
49 |
50 |
51 | #line 25 "..\..\MainWindow.xaml"
52 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
53 | internal System.Windows.Controls.Button AsyncStringTaskButton;
54 |
55 | #line default
56 | #line hidden
57 |
58 |
59 | #line 30 "..\..\MainWindow.xaml"
60 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
61 | internal System.Windows.Controls.Button TaskDotRunButton;
62 |
63 | #line default
64 | #line hidden
65 |
66 |
67 | #line 35 "..\..\MainWindow.xaml"
68 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
69 | internal System.Windows.Controls.Button RunAll;
70 |
71 | #line default
72 | #line hidden
73 |
74 |
75 | #line 45 "..\..\MainWindow.xaml"
76 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
77 | internal System.Windows.Controls.CheckBox CheckBox_DisableButton;
78 |
79 | #line default
80 | #line hidden
81 |
82 |
83 | #line 51 "..\..\MainWindow.xaml"
84 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
85 | internal System.Windows.Controls.TextBox TextBox_SleepTime;
86 |
87 | #line default
88 | #line hidden
89 |
90 |
91 | #line 55 "..\..\MainWindow.xaml"
92 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
93 | internal System.Windows.Controls.ListBox ListBoxResults;
94 |
95 | #line default
96 | #line hidden
97 |
98 |
99 | #line 64 "..\..\MainWindow.xaml"
100 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
101 | internal System.Windows.Controls.TextBlock TextBlock_Timer;
102 |
103 | #line default
104 | #line hidden
105 |
106 | private bool _contentLoaded;
107 |
108 | ///
109 | /// InitializeComponent
110 | ///
111 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
112 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
113 | public void InitializeComponent() {
114 | if (_contentLoaded) {
115 | return;
116 | }
117 | _contentLoaded = true;
118 | System.Uri resourceLocater = new System.Uri("/UnderstandingAsync;component/mainwindow.xaml", System.UriKind.Relative);
119 |
120 | #line 1 "..\..\MainWindow.xaml"
121 | System.Windows.Application.LoadComponent(this, resourceLocater);
122 |
123 | #line default
124 | #line hidden
125 | }
126 |
127 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
128 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
129 | [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
130 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
131 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
132 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
133 | void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
134 | switch (connectionId)
135 | {
136 | case 1:
137 | this.StringTaskButton = ((System.Windows.Controls.Button)(target));
138 |
139 | #line 23 "..\..\MainWindow.xaml"
140 | this.StringTaskButton.Click += new System.Windows.RoutedEventHandler(this.buttonClick);
141 |
142 | #line default
143 | #line hidden
144 | return;
145 | case 2:
146 | this.AsyncStringTaskButton = ((System.Windows.Controls.Button)(target));
147 |
148 | #line 28 "..\..\MainWindow.xaml"
149 | this.AsyncStringTaskButton.Click += new System.Windows.RoutedEventHandler(this.buttonClick);
150 |
151 | #line default
152 | #line hidden
153 | return;
154 | case 3:
155 | this.TaskDotRunButton = ((System.Windows.Controls.Button)(target));
156 |
157 | #line 33 "..\..\MainWindow.xaml"
158 | this.TaskDotRunButton.Click += new System.Windows.RoutedEventHandler(this.buttonClick);
159 |
160 | #line default
161 | #line hidden
162 | return;
163 | case 4:
164 | this.RunAll = ((System.Windows.Controls.Button)(target));
165 |
166 | #line 38 "..\..\MainWindow.xaml"
167 | this.RunAll.Click += new System.Windows.RoutedEventHandler(this.RunAll_Click);
168 |
169 | #line default
170 | #line hidden
171 | return;
172 | case 5:
173 |
174 | #line 44 "..\..\MainWindow.xaml"
175 | ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.ClearList_Click);
176 |
177 | #line default
178 | #line hidden
179 | return;
180 | case 6:
181 | this.CheckBox_DisableButton = ((System.Windows.Controls.CheckBox)(target));
182 | return;
183 | case 7:
184 | this.TextBox_SleepTime = ((System.Windows.Controls.TextBox)(target));
185 |
186 | #line 52 "..\..\MainWindow.xaml"
187 | this.TextBox_SleepTime.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.TextBox_TextChanged);
188 |
189 | #line default
190 | #line hidden
191 | return;
192 | case 8:
193 | this.ListBoxResults = ((System.Windows.Controls.ListBox)(target));
194 | return;
195 | case 9:
196 | this.TextBlock_Timer = ((System.Windows.Controls.TextBlock)(target));
197 | return;
198 | }
199 | this._contentLoaded = true;
200 | }
201 | }
202 | }
203 |
204 |
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Debug/MainWindow.g.i.cs:
--------------------------------------------------------------------------------
1 | #pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "657B25D0977E963ED5C01EE15B101492"
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version:4.0.30319.42000
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | //------------------------------------------------------------------------------
11 |
12 | using System;
13 | using System.Diagnostics;
14 | using System.Windows;
15 | using System.Windows.Automation;
16 | using System.Windows.Controls;
17 | using System.Windows.Controls.Primitives;
18 | using System.Windows.Data;
19 | using System.Windows.Documents;
20 | using System.Windows.Ink;
21 | using System.Windows.Input;
22 | using System.Windows.Markup;
23 | using System.Windows.Media;
24 | using System.Windows.Media.Animation;
25 | using System.Windows.Media.Effects;
26 | using System.Windows.Media.Imaging;
27 | using System.Windows.Media.Media3D;
28 | using System.Windows.Media.TextFormatting;
29 | using System.Windows.Navigation;
30 | using System.Windows.Shapes;
31 | using System.Windows.Shell;
32 |
33 |
34 | namespace UnderstandingAsync {
35 |
36 |
37 | ///
38 | /// MainWindow
39 | ///
40 | public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
41 |
42 |
43 | #line 21 "..\..\MainWindow.xaml"
44 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
45 | internal System.Windows.Controls.Button StringTaskButton;
46 |
47 | #line default
48 | #line hidden
49 |
50 |
51 | #line 25 "..\..\MainWindow.xaml"
52 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
53 | internal System.Windows.Controls.Button AsyncStringTaskButton;
54 |
55 | #line default
56 | #line hidden
57 |
58 |
59 | #line 30 "..\..\MainWindow.xaml"
60 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
61 | internal System.Windows.Controls.Button TaskDotRunButton;
62 |
63 | #line default
64 | #line hidden
65 |
66 |
67 | #line 35 "..\..\MainWindow.xaml"
68 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
69 | internal System.Windows.Controls.Button RunAll;
70 |
71 | #line default
72 | #line hidden
73 |
74 |
75 | #line 45 "..\..\MainWindow.xaml"
76 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
77 | internal System.Windows.Controls.CheckBox CheckBox_DisableButton;
78 |
79 | #line default
80 | #line hidden
81 |
82 |
83 | #line 51 "..\..\MainWindow.xaml"
84 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
85 | internal System.Windows.Controls.TextBox TextBox_SleepTime;
86 |
87 | #line default
88 | #line hidden
89 |
90 |
91 | #line 55 "..\..\MainWindow.xaml"
92 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
93 | internal System.Windows.Controls.ListBox ListBoxResults;
94 |
95 | #line default
96 | #line hidden
97 |
98 |
99 | #line 64 "..\..\MainWindow.xaml"
100 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
101 | internal System.Windows.Controls.TextBlock TextBlock_Timer;
102 |
103 | #line default
104 | #line hidden
105 |
106 | private bool _contentLoaded;
107 |
108 | ///
109 | /// InitializeComponent
110 | ///
111 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
112 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
113 | public void InitializeComponent() {
114 | if (_contentLoaded) {
115 | return;
116 | }
117 | _contentLoaded = true;
118 | System.Uri resourceLocater = new System.Uri("/UnderstandingAsync;component/mainwindow.xaml", System.UriKind.Relative);
119 |
120 | #line 1 "..\..\MainWindow.xaml"
121 | System.Windows.Application.LoadComponent(this, resourceLocater);
122 |
123 | #line default
124 | #line hidden
125 | }
126 |
127 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
128 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
129 | [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
130 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
131 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
132 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
133 | void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
134 | switch (connectionId)
135 | {
136 | case 1:
137 | this.StringTaskButton = ((System.Windows.Controls.Button)(target));
138 |
139 | #line 23 "..\..\MainWindow.xaml"
140 | this.StringTaskButton.Click += new System.Windows.RoutedEventHandler(this.buttonClick);
141 |
142 | #line default
143 | #line hidden
144 | return;
145 | case 2:
146 | this.AsyncStringTaskButton = ((System.Windows.Controls.Button)(target));
147 |
148 | #line 28 "..\..\MainWindow.xaml"
149 | this.AsyncStringTaskButton.Click += new System.Windows.RoutedEventHandler(this.buttonClick);
150 |
151 | #line default
152 | #line hidden
153 | return;
154 | case 3:
155 | this.TaskDotRunButton = ((System.Windows.Controls.Button)(target));
156 |
157 | #line 33 "..\..\MainWindow.xaml"
158 | this.TaskDotRunButton.Click += new System.Windows.RoutedEventHandler(this.buttonClick);
159 |
160 | #line default
161 | #line hidden
162 | return;
163 | case 4:
164 | this.RunAll = ((System.Windows.Controls.Button)(target));
165 |
166 | #line 38 "..\..\MainWindow.xaml"
167 | this.RunAll.Click += new System.Windows.RoutedEventHandler(this.RunAll_Click);
168 |
169 | #line default
170 | #line hidden
171 | return;
172 | case 5:
173 |
174 | #line 44 "..\..\MainWindow.xaml"
175 | ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.ClearList_Click);
176 |
177 | #line default
178 | #line hidden
179 | return;
180 | case 6:
181 | this.CheckBox_DisableButton = ((System.Windows.Controls.CheckBox)(target));
182 | return;
183 | case 7:
184 | this.TextBox_SleepTime = ((System.Windows.Controls.TextBox)(target));
185 |
186 | #line 52 "..\..\MainWindow.xaml"
187 | this.TextBox_SleepTime.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.TextBox_TextChanged);
188 |
189 | #line default
190 | #line hidden
191 | return;
192 | case 8:
193 | this.ListBoxResults = ((System.Windows.Controls.ListBox)(target));
194 | return;
195 | case 9:
196 | this.TextBlock_Timer = ((System.Windows.Controls.TextBlock)(target));
197 | return;
198 | }
199 | this._contentLoaded = true;
200 | }
201 | }
202 | }
203 |
204 |
--------------------------------------------------------------------------------
/UnderstandingAsync/obj/Release/MainWindow.g.cs:
--------------------------------------------------------------------------------
1 | #pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "545050E9BDD3F2AE558E010373C59919"
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version:4.0.30319.42000
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | //------------------------------------------------------------------------------
11 |
12 | using System;
13 | using System.Diagnostics;
14 | using System.Windows;
15 | using System.Windows.Automation;
16 | using System.Windows.Controls;
17 | using System.Windows.Controls.Primitives;
18 | using System.Windows.Data;
19 | using System.Windows.Documents;
20 | using System.Windows.Ink;
21 | using System.Windows.Input;
22 | using System.Windows.Markup;
23 | using System.Windows.Media;
24 | using System.Windows.Media.Animation;
25 | using System.Windows.Media.Effects;
26 | using System.Windows.Media.Imaging;
27 | using System.Windows.Media.Media3D;
28 | using System.Windows.Media.TextFormatting;
29 | using System.Windows.Navigation;
30 | using System.Windows.Shapes;
31 | using System.Windows.Shell;
32 |
33 |
34 | namespace UnderstandingAsync {
35 |
36 |
37 | ///
38 | /// MainWindow
39 | ///
40 | public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
41 |
42 |
43 | #line 18 "..\..\MainWindow.xaml"
44 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
45 | internal System.Windows.Controls.Button String_WithAsynLabel;
46 |
47 | #line default
48 | #line hidden
49 |
50 |
51 | #line 19 "..\..\MainWindow.xaml"
52 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
53 | internal System.Windows.Controls.Button String_WithTaskRun;
54 |
55 | #line default
56 | #line hidden
57 |
58 |
59 | #line 20 "..\..\MainWindow.xaml"
60 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
61 | internal System.Windows.Controls.Button String_WithTaskFromResultAsWhole;
62 |
63 | #line default
64 | #line hidden
65 |
66 |
67 | #line 21 "..\..\MainWindow.xaml"
68 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
69 | internal System.Windows.Controls.Button RunAll;
70 |
71 | #line default
72 | #line hidden
73 |
74 |
75 | #line 23 "..\..\MainWindow.xaml"
76 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
77 | internal System.Windows.Controls.Button ClearList;
78 |
79 | #line default
80 | #line hidden
81 |
82 |
83 | #line 24 "..\..\MainWindow.xaml"
84 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
85 | internal System.Windows.Controls.CheckBox CheckBox_DisableButton;
86 |
87 | #line default
88 | #line hidden
89 |
90 |
91 | #line 26 "..\..\MainWindow.xaml"
92 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
93 | internal System.Windows.Controls.TextBox TextBox_SleepTime;
94 |
95 | #line default
96 | #line hidden
97 |
98 |
99 | #line 30 "..\..\MainWindow.xaml"
100 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
101 | internal System.Windows.Controls.ListBox ListBoxResults;
102 |
103 | #line default
104 | #line hidden
105 |
106 |
107 | #line 31 "..\..\MainWindow.xaml"
108 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
109 | internal System.Windows.Controls.TextBlock TextBlock_Timer;
110 |
111 | #line default
112 | #line hidden
113 |
114 | private bool _contentLoaded;
115 |
116 | ///
117 | /// InitializeComponent
118 | ///
119 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
120 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
121 | public void InitializeComponent() {
122 | if (_contentLoaded) {
123 | return;
124 | }
125 | _contentLoaded = true;
126 | System.Uri resourceLocater = new System.Uri("/UnderstandingAsync;component/mainwindow.xaml", System.UriKind.Relative);
127 |
128 | #line 1 "..\..\MainWindow.xaml"
129 | System.Windows.Application.LoadComponent(this, resourceLocater);
130 |
131 | #line default
132 | #line hidden
133 | }
134 |
135 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
136 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
137 | [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
138 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
139 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
140 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
141 | void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
142 | switch (connectionId)
143 | {
144 | case 1:
145 |
146 | #line 4 "..\..\MainWindow.xaml"
147 | ((UnderstandingAsync.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);
148 |
149 | #line default
150 | #line hidden
151 |
152 | #line 4 "..\..\MainWindow.xaml"
153 | ((UnderstandingAsync.MainWindow)(target)).Closing += new System.ComponentModel.CancelEventHandler(this.Window_Closing);
154 |
155 | #line default
156 | #line hidden
157 | return;
158 | case 2:
159 | this.String_WithAsynLabel = ((System.Windows.Controls.Button)(target));
160 |
161 | #line 18 "..\..\MainWindow.xaml"
162 | this.String_WithAsynLabel.Click += new System.Windows.RoutedEventHandler(this.String_WithAsynLabel_Click);
163 |
164 | #line default
165 | #line hidden
166 | return;
167 | case 3:
168 | this.String_WithTaskRun = ((System.Windows.Controls.Button)(target));
169 |
170 | #line 19 "..\..\MainWindow.xaml"
171 | this.String_WithTaskRun.Click += new System.Windows.RoutedEventHandler(this.String_WithTaskRun_Click);
172 |
173 | #line default
174 | #line hidden
175 | return;
176 | case 4:
177 | this.String_WithTaskFromResultAsWhole = ((System.Windows.Controls.Button)(target));
178 |
179 | #line 20 "..\..\MainWindow.xaml"
180 | this.String_WithTaskFromResultAsWhole.Click += new System.Windows.RoutedEventHandler(this.String_WithTaskFromResultAsWhole_Click);
181 |
182 | #line default
183 | #line hidden
184 | return;
185 | case 5:
186 | this.RunAll = ((System.Windows.Controls.Button)(target));
187 |
188 | #line 21 "..\..\MainWindow.xaml"
189 | this.RunAll.Click += new System.Windows.RoutedEventHandler(this.RunAll_Click);
190 |
191 | #line default
192 | #line hidden
193 | return;
194 | case 6:
195 | this.ClearList = ((System.Windows.Controls.Button)(target));
196 |
197 | #line 23 "..\..\MainWindow.xaml"
198 | this.ClearList.Click += new System.Windows.RoutedEventHandler(this.ClearList_Click);
199 |
200 | #line default
201 | #line hidden
202 | return;
203 | case 7:
204 | this.CheckBox_DisableButton = ((System.Windows.Controls.CheckBox)(target));
205 | return;
206 | case 8:
207 | this.TextBox_SleepTime = ((System.Windows.Controls.TextBox)(target));
208 |
209 | #line 26 "..\..\MainWindow.xaml"
210 | this.TextBox_SleepTime.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.TextBox_TextChanged);
211 |
212 | #line default
213 | #line hidden
214 | return;
215 | case 9:
216 | this.ListBoxResults = ((System.Windows.Controls.ListBox)(target));
217 | return;
218 | case 10:
219 | this.TextBlock_Timer = ((System.Windows.Controls.TextBlock)(target));
220 | return;
221 | }
222 | this._contentLoaded = true;
223 | }
224 | }
225 | }
226 |
227 |
--------------------------------------------------------------------------------