├── .gitignore ├── AsyncAwait ├── .gitignore ├── 1. FromSyncToAsync │ ├── 01. FromSyncToAsync.csproj │ └── Program.cs ├── 10. TasksBehindTheScenes │ ├── 10. TasksBehindTheScenes.csproj │ ├── EventBasedApi.cs │ └── Program.cs ├── 11. CustomAwait │ ├── 11. CustomAwait.csproj │ ├── Awaiters.cs │ └── Program.cs ├── 12. ChildTasks │ ├── 12. ChildTasks.csproj │ └── Program.cs ├── 13. StateMachine │ ├── 13. StateMachine.csproj │ ├── Compiled.cs │ └── Program.cs ├── 2. BurgerPreparation │ ├── 02. BurgerPreparation.csproj │ ├── AllAtOnceCooker.cs │ ├── AsyncCooker.cs │ ├── Program.cs │ └── SyncCooker.cs ├── 3. MultithreadingAndAsynchronous │ ├── 03. MultithreadingAndAsynchronous.csproj │ └── Program.cs ├── 4. TaskMethods │ ├── 04. TaskMethods.csproj │ └── Program.cs ├── 5. AsyncAwait │ ├── 05. AsyncAwait.csproj │ ├── Extensions.cs │ └── Program.cs ├── 6. PerformanceExample │ ├── 06. PerformanceExample.csproj │ ├── Images │ │ ├── 1.jpg │ │ ├── 10.jpg │ │ ├── 11.jpg │ │ ├── 12.jpg │ │ ├── 13.jpg │ │ ├── 14.jpg │ │ ├── 15.jpg │ │ ├── 16.jpg │ │ ├── 17.jpg │ │ ├── 18.jpg │ │ ├── 19.jpg │ │ ├── 2.jpg │ │ ├── 20.jpg │ │ ├── 21.jpg │ │ ├── 22.jpg │ │ ├── 23.jpg │ │ ├── 24.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ ├── 5.jpg │ │ ├── 6.jpg │ │ ├── 7.jpg │ │ ├── 8.jpg │ │ ├── 9.jpg │ │ └── MoreThanCpuSync │ │ │ ├── 1.jpg │ │ │ ├── 10.jpg │ │ │ ├── 11.jpg │ │ │ ├── 12.jpg │ │ │ ├── 13.jpg │ │ │ ├── 14.jpg │ │ │ ├── 15.jpg │ │ │ └── 16.jpg │ └── Program.cs ├── 7. Gotchas │ ├── 07. Gotchas.csproj │ └── Program.cs ├── 8. Deadlock │ ├── 08. Deadlock.csproj │ ├── App_Start │ │ ├── BundleConfig.cs │ │ ├── FilterConfig.cs │ │ └── RouteConfig.cs │ ├── Content │ │ ├── Site.css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap-theme.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ ├── Controllers │ │ └── HomeController.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Scripts │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── jquery-3.4.1.intellisense.js │ │ ├── jquery-3.4.1.js │ │ ├── jquery-3.4.1.min.js │ │ ├── jquery-3.4.1.min.map │ │ ├── jquery-3.4.1.slim.js │ │ ├── jquery-3.4.1.slim.min.js │ │ ├── jquery-3.4.1.slim.min.map │ │ ├── jquery.validate-vsdoc.js │ │ ├── jquery.validate.js │ │ ├── jquery.validate.min.js │ │ ├── jquery.validate.unobtrusive.js │ │ ├── jquery.validate.unobtrusive.min.js │ │ └── modernizr-2.8.3.js │ ├── Views │ │ ├── Home │ │ │ ├── About.cshtml │ │ │ ├── Contact.cshtml │ │ │ └── Index.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ └── _Layout.cshtml │ │ ├── Web.config │ │ └── _ViewStart.cshtml │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Web.config │ ├── favicon.ico │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ └── packages.config ├── 9. Cancellation │ ├── 09. Cancellation.csproj │ └── Program.cs └── AsynAwaitPlayground.sln ├── LICENSE ├── MyConsoleApp ├── MyConsoleApp.sln └── MyConsoleApp │ ├── Cat.cs │ ├── MyConsoleApp.csproj │ └── Program.cs ├── README.md └── Test.txt /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /AsyncAwait/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /AsyncAwait/1. FromSyncToAsync/01. FromSyncToAsync.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | FromSyncToAsync 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/1. FromSyncToAsync/Program.cs: -------------------------------------------------------------------------------- 1 | namespace FromSyncToAsync 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | 6 | public class Program 7 | { 8 | public static void Main() 9 | { 10 | // SimpleExample(); 11 | ComplexExample(); 12 | } 13 | 14 | public static void SimpleExample() 15 | { 16 | var task = Task.Run(() => Console.WriteLine("First!")); 17 | 18 | Console.WriteLine("Second"); 19 | 20 | task.Wait(); 21 | } 22 | 23 | public static void ComplexExample() 24 | { 25 | var task = Task 26 | .Run(() => Task 27 | .Delay(2000) 28 | .ContinueWith(t => "In a task")); 29 | 30 | Task.Delay(4000).Wait(); 31 | Console.WriteLine("Outside of a task!"); 32 | 33 | var completion = Task 34 | .WhenAll(task) 35 | .ContinueWith(async t => 36 | { 37 | Console.WriteLine((await t)[0]); 38 | }); 39 | 40 | completion.Wait(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AsyncAwait/10. TasksBehindTheScenes/10. TasksBehindTheScenes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | TasksBehindTheScenes 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/10. TasksBehindTheScenes/EventBasedApi.cs: -------------------------------------------------------------------------------- 1 | namespace TasksBehindTheScenes 2 | { 3 | using System; 4 | 5 | public class EventBasedApi 6 | { 7 | public event Action OnDone = s => { }; 8 | 9 | public void Work() 10 | { 11 | Console.WriteLine("Working..."); 12 | 13 | var end = DateTime.Now.AddSeconds(5); 14 | 15 | while (true) 16 | { 17 | if (DateTime.Now > end) 18 | { 19 | break; 20 | } 21 | } 22 | 23 | Console.WriteLine("Done..."); 24 | 25 | this.OnDone("Data"); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /AsyncAwait/10. TasksBehindTheScenes/Program.cs: -------------------------------------------------------------------------------- 1 | namespace TasksBehindTheScenes 2 | { 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | public class Program 8 | { 9 | public static async Task Main() 10 | { 11 | var result = await RunAsync(() => true); 12 | Console.WriteLine(result); 13 | 14 | await DelayAsync(2000, () => Console.WriteLine("Delayed!")); 15 | 16 | await RunCancellation(); 17 | 18 | var eventBasedResult = await EventBasedApiWrapper(); 19 | Console.WriteLine(eventBasedResult); 20 | } 21 | 22 | public static async Task RunCancellation() 23 | { 24 | var cancellation = new CancellationTokenSource(); 25 | var counter = 0; 26 | 27 | var task = Task.Run(async () => 28 | { 29 | while (true) 30 | { 31 | if (counter == 5) 32 | { 33 | cancellation.Cancel(); 34 | break; 35 | } 36 | 37 | await Task.Delay(1000); 38 | 39 | Console.WriteLine(DateTime.Now); 40 | 41 | counter++; 42 | } 43 | }); 44 | 45 | var cancellationEnd = Task.Run(() => Console.WriteLine("End")); 46 | 47 | await Task.WhenAll( 48 | task, 49 | RunUntilCancellation(cancellation.Token, () => cancellationEnd)); 50 | } 51 | 52 | public static Task RunAsync(Func function) 53 | { 54 | if (function == null) 55 | { 56 | throw new ArgumentNullException(nameof(function)); 57 | } 58 | 59 | var tcs = new TaskCompletionSource(); 60 | 61 | ThreadPool.QueueUserWorkItem(_ => 62 | { 63 | try 64 | { 65 | var result = function(); 66 | tcs.SetResult(result); 67 | } 68 | catch (Exception exc) 69 | { 70 | tcs.SetException(exc); 71 | } 72 | }); 73 | 74 | return tcs.Task; 75 | } 76 | 77 | public static Task DelayAsync(int millisecondsDelay, Action action) 78 | { 79 | if (millisecondsDelay < 0) 80 | { 81 | throw new ArgumentOutOfRangeException(nameof(millisecondsDelay)); 82 | } 83 | 84 | if (action == null) 85 | { 86 | throw new ArgumentNullException(nameof(action)); 87 | } 88 | 89 | var tcs = new TaskCompletionSource(); 90 | 91 | var timer = new Timer( 92 | _ => tcs.SetResult(null), null, millisecondsDelay, Timeout.Infinite); 93 | 94 | return tcs.Task.ContinueWith(_ => 95 | { 96 | timer.Dispose(); 97 | action(); 98 | }); 99 | } 100 | 101 | public static Task RunUntilCancellation( 102 | CancellationToken cancellationToken, 103 | Func onCancel) 104 | { 105 | var tcs = new TaskCompletionSource(); 106 | 107 | cancellationToken.Register( 108 | async () => 109 | { 110 | await onCancel(); 111 | tcs.SetResult(true); 112 | }); 113 | 114 | return tcs.Task; 115 | } 116 | 117 | public static Task EventBasedApiWrapper() 118 | { 119 | var tcs = new TaskCompletionSource(); 120 | 121 | var obj = new EventBasedApi(); 122 | 123 | obj.OnDone += arg => 124 | { 125 | // This will notify the caller 126 | // of the EventBasedApiWrapper that 127 | // the task just completed. 128 | tcs.SetResult(arg); 129 | }; 130 | 131 | // Start the event-based work. 132 | obj.Work(); 133 | 134 | return tcs.Task; 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /AsyncAwait/11. CustomAwait/11. CustomAwait.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | CustomAwait 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/11. CustomAwait/Awaiters.cs: -------------------------------------------------------------------------------- 1 | namespace CustomAwait 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Net.Http; 6 | using System.Runtime.CompilerServices; 7 | using System.Threading.Tasks; 8 | 9 | public static class Awaiters 10 | { 11 | public static TaskAwaiter GetAwaiter(this Uri uri) 12 | => new HttpClient().GetStringAsync(uri).GetAwaiter(); 13 | 14 | public static TaskAwaiter GetAwaiter(this TimeSpan timeSpan) 15 | => Task.Delay(timeSpan).GetAwaiter(); 16 | 17 | public static TaskAwaiter GetAwaiter(this int number) 18 | => TimeSpan.FromMilliseconds(number).GetAwaiter(); 19 | 20 | public static TaskAwaiter GetAwaiter(this IEnumerable tasks) 21 | => Task.WhenAll(tasks).GetAwaiter(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AsyncAwait/11. CustomAwait/Program.cs: -------------------------------------------------------------------------------- 1 | namespace CustomAwait 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | public class Program 8 | { 9 | public static async Task Main() 10 | { 11 | var content = await new Uri("https://mytestedasp.net"); 12 | 13 | Console.WriteLine(content); 14 | 15 | await TimeSpan.FromSeconds(3); 16 | 17 | await 1000; // In milliseconds. 18 | 19 | await new List 20 | { 21 | Task.Delay(1000), 22 | Task.Delay(2000) 23 | }; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AsyncAwait/12. ChildTasks/12. ChildTasks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | ChildTasks 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/12. ChildTasks/Program.cs: -------------------------------------------------------------------------------- 1 | namespace ChildTasks 2 | { 3 | using System; 4 | using System.Threading.Tasks; 5 | 6 | public class Program 7 | { 8 | public static async Task Main(string[] args) 9 | { 10 | // Detached(); 11 | Attached(); 12 | 13 | await DetachedAsync(); 14 | } 15 | 16 | public static void Detached() 17 | { 18 | Task 19 | .Factory 20 | .StartNew(() => 21 | { 22 | Console.WriteLine("First task detached"); 23 | 24 | Task.Factory.StartNew(() => 25 | { 26 | Task.Delay(10000).Wait(); 27 | Console.WriteLine("Second task detached"); 28 | }); 29 | }) 30 | .Wait(); 31 | } 32 | 33 | public static void Attached() 34 | { 35 | Task 36 | .Factory 37 | .StartNew(() => 38 | { 39 | Console.WriteLine("First task attached"); 40 | 41 | Task.Factory.StartNew(() => 42 | { 43 | Task.Delay(2000).Wait(); 44 | Console.WriteLine("Second task attached"); 45 | }, TaskCreationOptions.AttachedToParent); 46 | }) 47 | .Wait(); 48 | } 49 | 50 | private static async Task DetachedAsync() 51 | { 52 | await Task.Run(async () => 53 | { 54 | Console.WriteLine("First task async"); 55 | 56 | await Task.Run(async () => 57 | { 58 | await Task.Delay(4000); 59 | Console.WriteLine("Second task async"); 60 | }); 61 | }); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /AsyncAwait/13. StateMachine/13. StateMachine.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | StateMachine 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/13. StateMachine/Compiled.cs: -------------------------------------------------------------------------------- 1 | namespace StateMachine 2 | { 3 | using System; 4 | using System.Runtime.CompilerServices; 5 | using System.Threading.Tasks; 6 | 7 | public class Compiled 8 | { 9 | private sealed class InputContext 10 | { 11 | public int input; 12 | 13 | internal void ConsoleWriteLine() 14 | { 15 | Console.WriteLine(input); 16 | } 17 | } 18 | 19 | private sealed class ReturnContext 20 | { 21 | public static readonly ReturnContext Context = new ReturnContext(); 22 | 23 | public static Func FunctionCall; 24 | 25 | internal bool ReturnTrue() 26 | { 27 | return true; 28 | } 29 | } 30 | 31 | private sealed class TaskStateMachine : IAsyncStateMachine 32 | { 33 | // Initial value = -1 34 | public int state; 35 | 36 | // Task builder 37 | public AsyncTaskMethodBuilder taskBuilder; 38 | 39 | public string[] args; 40 | 41 | // Context of the first awaited task 42 | private InputContext inputContext; 43 | 44 | // Result of the second awaited task 45 | private bool result; 46 | 47 | // Execution context 48 | private TaskAwaiter FirstAwaiter; 49 | 50 | // Execution context 51 | private TaskAwaiter SecondAwaiter; 52 | 53 | // This is the section where actual logic of original method exist 54 | // Contain the logic to execute the code till await statement 55 | // Also configure stuff of the wake up call when async method complete it's execution 56 | public void MoveNext() 57 | { 58 | // Set state to local variable for performance 59 | int num = state; 60 | try 61 | { 62 | // Variables to save awaiters for the new tasks 63 | TaskAwaiter firstAwaiter; 64 | TaskAwaiter secondAwaiter; 65 | 66 | // Initially -1 67 | if (num != 0) 68 | { 69 | if (num == 1) 70 | { 71 | // We get the awaiter from the execution context again 72 | secondAwaiter = SecondAwaiter; 73 | 74 | // Set to null to release memory allocation 75 | SecondAwaiter = default; 76 | 77 | // Restart the state as we are about to finish 78 | num = (state = -1); 79 | 80 | // Don't use goto unless you know what you are doing! :) 81 | goto IL_0114; 82 | } 83 | 84 | // Execute first task with its context 85 | inputContext = new InputContext(); 86 | inputContext.input = 5; 87 | firstAwaiter = Task.Run(inputContext.ConsoleWriteLine).GetAwaiter(); 88 | 89 | // This block is for optimization in case the task is already finished (Task.FromResult) 90 | // Most probably - this block will be executed 91 | if (!firstAwaiter.IsCompleted) 92 | { 93 | num = (state = 0); 94 | // Save the awaiter for the next state. 95 | FirstAwaiter = firstAwaiter; 96 | TaskStateMachine stateMachine = this; 97 | 98 | // This call to AwaitUnsafeOnCompleted is where most of the magic happens 99 | // In this step we register the StateMachine as continuation of the task by calling AwaitUnsafeOnCompleted 100 | // But how it is done? 101 | // builder.AwaitUnsafeOnCompleted do multiple things in background 102 | // 1. TaskMethodBuilder captures Execution context 103 | // 2. Create an MoveNextAction using Execution context 104 | // 3. This MoveNextAction will call the MoveNext of state machine and provide execution context 105 | // 4. Set MoveNextAction as callback to awaiter on complete Using awaiter.UnsafeOnCompleted(action) 106 | taskBuilder.AwaitUnsafeOnCompleted(ref firstAwaiter, ref stateMachine); 107 | return; 108 | } 109 | } 110 | else 111 | { 112 | // Second time - we get the awaiter from the execution context 113 | firstAwaiter = FirstAwaiter; 114 | 115 | // Set to null to release memory allocation 116 | FirstAwaiter = default; 117 | num = (state = -1); 118 | } 119 | 120 | firstAwaiter.GetResult(); 121 | 122 | // Execute second task with its context 123 | secondAwaiter = Task 124 | .Run(ReturnContext.FunctionCall ?? (ReturnContext.FunctionCall = ReturnContext.Context.ReturnTrue)) 125 | .GetAwaiter(); 126 | 127 | // Again - for optimization 128 | if (!secondAwaiter.IsCompleted) 129 | { 130 | num = (state = 1); 131 | // Save the awaiter for the next state. 132 | SecondAwaiter = secondAwaiter; 133 | TaskStateMachine stateMachine = this; 134 | // Register the state machine to continue with the next state 135 | taskBuilder.AwaitUnsafeOnCompleted(ref secondAwaiter, ref stateMachine); 136 | return; 137 | } 138 | 139 | IL_0114: 140 | // Finish by getting the awaiter result and execute the logic 141 | result = secondAwaiter.GetResult(); 142 | Console.WriteLine(result); 143 | } 144 | catch (Exception exception) 145 | { 146 | // Exception handling mechanism 147 | state = -2; 148 | taskBuilder.SetException(exception); 149 | return; 150 | } 151 | 152 | // Set the state to final state we are done 153 | state = -2; 154 | 155 | // Set the result on the task builder 156 | taskBuilder.SetResult(); 157 | } 158 | 159 | public void SetStateMachine(IAsyncStateMachine stateMachine) 160 | { 161 | } 162 | } 163 | 164 | public static Task MainCompiled(string[] args) 165 | { 166 | var taskMethodBuilder = AsyncTaskMethodBuilder.Create(); 167 | 168 | TaskStateMachine stateMachine = new TaskStateMachine(); 169 | stateMachine.args = args; 170 | stateMachine.taskBuilder = taskMethodBuilder; 171 | stateMachine.state = -1; 172 | 173 | taskMethodBuilder.Start(ref stateMachine); 174 | 175 | return stateMachine.taskBuilder.Task; 176 | } 177 | } 178 | } -------------------------------------------------------------------------------- /AsyncAwait/13. StateMachine/Program.cs: -------------------------------------------------------------------------------- 1 | namespace StateMachine 2 | { 3 | using System; 4 | using System.Linq; 5 | using System.Net.Http; 6 | using System.Reflection; 7 | using System.Threading.Tasks; 8 | 9 | public class Program 10 | { 11 | public static async Task Main(string[] args) 12 | { 13 | // Prints all state machines in the console. 14 | Assembly 15 | .GetExecutingAssembly() 16 | .GetTypes() 17 | .Where(d => d.Name.Contains("d_")) 18 | .ToList() 19 | .ForEach(Console.WriteLine); 20 | 21 | await Compiled.MainCompiled(args); 22 | } 23 | 24 | public static async Task StateMachineCompiled() 25 | { 26 | int input = 5; 27 | 28 | await Task.Run(() => 29 | { 30 | Console.WriteLine(input); 31 | }); 32 | 33 | var result = await Task.Run(() => true); 34 | 35 | Console.WriteLine(result); 36 | } 37 | 38 | public static async Task HardcoreStateMachineCompiled() 39 | { 40 | var input = 5; 41 | var secondInput = Console.ReadLine(); 42 | 43 | var result = await Task 44 | .Run(() => 45 | { 46 | Console.WriteLine(input); 47 | }) 48 | .ContinueWith(async task => 49 | { 50 | await Task 51 | .Delay(3000) 52 | .ContinueWith(_ => 53 | { 54 | Console.WriteLine(secondInput); 55 | }); 56 | }) 57 | .ContinueWith(t => 58 | { 59 | return Task.Run(() => true); 60 | }); 61 | 62 | Console.WriteLine(await result); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /AsyncAwait/2. BurgerPreparation/02. BurgerPreparation.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | BurgerPreparation 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/2. BurgerPreparation/AllAtOnceCooker.cs: -------------------------------------------------------------------------------- 1 | namespace BurgerPreparation 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | public static class AllAtOnceCooker 8 | { 9 | public static async Task Work() 10 | { 11 | var tasks = new List 12 | { 13 | HeatThePans(), 14 | UnfreezeMeat(), 15 | PeelPotatoes(), 16 | CookBurgers(), 17 | FryFries(), 18 | PourDrinks(), 19 | ServeAndEat() 20 | }; 21 | 22 | await Task.WhenAll(tasks); 23 | } 24 | 25 | public static async Task HeatThePans() 26 | { 27 | await Task.Delay(2000); 28 | Console.WriteLine("Pan heated!"); 29 | } 30 | 31 | public static async Task UnfreezeMeat() 32 | { 33 | await Task.Delay(3000); 34 | Console.WriteLine("Meat ready!"); 35 | } 36 | 37 | public static async Task PeelPotatoes() 38 | { 39 | await Task.Delay(2000); 40 | Console.WriteLine("Potatoes peeled!"); 41 | } 42 | 43 | public static async Task CookBurgers() 44 | { 45 | await Task.Delay(5000); 46 | Console.WriteLine("Burgers cooked!"); 47 | } 48 | 49 | public static async Task FryFries() 50 | { 51 | await Task.Delay(3000); 52 | Console.WriteLine("Fries fried!"); 53 | } 54 | 55 | public static async Task PourDrinks() 56 | { 57 | await Task.Delay(1000); 58 | Console.WriteLine("Drinks poured!"); 59 | } 60 | 61 | public static async Task ServeAndEat() 62 | { 63 | await Task.Delay(5000); 64 | Console.WriteLine("Delicious!"); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /AsyncAwait/2. BurgerPreparation/AsyncCooker.cs: -------------------------------------------------------------------------------- 1 | namespace BurgerPreparation 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | public class AsyncCooker 8 | { 9 | public static async Task Work() 10 | { 11 | await Task.WhenAll( 12 | HeatThePans(), 13 | UnfreezeMeat(), 14 | PeelPotatoes()); 15 | 16 | await Task.WhenAll( 17 | CookBurgers(), 18 | FryFries(), 19 | PourDrinks()); 20 | 21 | await ServeAndEat(); 22 | } 23 | 24 | public static async Task HeatThePans() 25 | { 26 | await Task.Delay(2000); 27 | Console.WriteLine("Pan heated!"); 28 | } 29 | 30 | public static async Task UnfreezeMeat() 31 | { 32 | await Task.Delay(3000); 33 | Console.WriteLine("Meat ready!"); 34 | } 35 | 36 | public static async Task PeelPotatoes() 37 | { 38 | await Task.Delay(2000); 39 | Console.WriteLine("Potatoes peeled!"); 40 | } 41 | 42 | public static async Task CookBurgers() 43 | { 44 | await Task.Delay(5000); 45 | Console.WriteLine("Burgers cooked!"); 46 | } 47 | 48 | public static async Task FryFries() 49 | { 50 | await Task.Delay(3000); 51 | Console.WriteLine("Fries fried!"); 52 | } 53 | 54 | public static async Task PourDrinks() 55 | { 56 | await Task.Delay(1000); 57 | Console.WriteLine("Drinks poured!"); 58 | } 59 | 60 | public static async Task ServeAndEat() 61 | { 62 | await Task.Delay(5000); 63 | Console.WriteLine("Delicious!"); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /AsyncAwait/2. BurgerPreparation/Program.cs: -------------------------------------------------------------------------------- 1 | namespace BurgerPreparation 2 | { 3 | using System.Threading.Tasks; 4 | 5 | public class Program 6 | { 7 | public static async Task Main(string[] args) 8 | { 9 | // SyncCooker.Work(); 10 | // await AllAtOnceCooker.Work(); 11 | await AsyncCooker.Work(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /AsyncAwait/2. BurgerPreparation/SyncCooker.cs: -------------------------------------------------------------------------------- 1 | namespace BurgerPreparation 2 | { 3 | using System; 4 | using System.Threading; 5 | 6 | public static class SyncCooker 7 | { 8 | public static void Work() 9 | { 10 | HeatThePans(); 11 | UnfreezeMeat(); 12 | PeelPotatoes(); 13 | CookBurgers(); 14 | FryFries(); 15 | PourDrinks(); 16 | ServeAndEat(); 17 | } 18 | 19 | public static void HeatThePans() 20 | { 21 | Thread.Sleep(2000); 22 | Console.WriteLine("Pan heated!"); 23 | } 24 | 25 | public static void UnfreezeMeat() 26 | { 27 | Thread.Sleep(3000); 28 | Console.WriteLine("Meat ready!"); 29 | } 30 | 31 | public static void PeelPotatoes() 32 | { 33 | Thread.Sleep(2000); 34 | Console.WriteLine("Potatoes peeled!"); 35 | } 36 | 37 | public static void CookBurgers() 38 | { 39 | Thread.Sleep(5000); 40 | Console.WriteLine("Burgers cooked!"); 41 | } 42 | 43 | public static void FryFries() 44 | { 45 | Thread.Sleep(3000); 46 | Console.WriteLine("Fries fried!"); 47 | } 48 | 49 | public static void PourDrinks() 50 | { 51 | Thread.Sleep(1000); 52 | Console.WriteLine("Drinks poured!"); 53 | } 54 | 55 | public static void ServeAndEat() 56 | { 57 | Thread.Sleep(5000); 58 | Console.WriteLine("Delicious!"); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /AsyncAwait/3. MultithreadingAndAsynchronous/03. MultithreadingAndAsynchronous.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | MultithreadingAndAsynchronous 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/3. MultithreadingAndAsynchronous/Program.cs: -------------------------------------------------------------------------------- 1 | namespace MultithreadingAndAsynchronous 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading; 7 | 8 | public class Program 9 | { 10 | private static readonly List Data = Enumerable.Range(0, 100).ToList(); 11 | 12 | public static void Main() 13 | { 14 | for (int i = 0; i < 4; i++) 15 | { 16 | var thread = new Thread(Work); 17 | thread.Start(); 18 | 19 | //if (i % 2 == 0) 20 | //{ 21 | // thread.Join(); 22 | //} 23 | } 24 | 25 | Console.WriteLine(Data.Count); 26 | } 27 | 28 | public static void Work() 29 | { 30 | for (int i = 0; i < 5; i++) 31 | { 32 | Console.WriteLine(i); 33 | 34 | Thread.Sleep(500); 35 | 36 | if (Data.Count > 90) 37 | { 38 | Data.RemoveAt(Data.Count - 1); 39 | } 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AsyncAwait/4. TaskMethods/04. TaskMethods.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | TaskMethods 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/4. TaskMethods/Program.cs: -------------------------------------------------------------------------------- 1 | namespace TaskMethods 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Net.Http; 7 | using System.Threading.Tasks; 8 | 9 | public class Program 10 | { 11 | public static void Main() 12 | { 13 | // WaitForTask(); 14 | // TaskContinuation(); 15 | // TaskExceptionsAndStatus(); 16 | // MultipleTasksAtTheSameTime(); 17 | // AtLeastOneTaskToFinish(); 18 | // CompletedTaskAndFromResult(); 19 | DownloadContentAndSaveItToFile(); 20 | } 21 | 22 | public static void WaitForTask() 23 | { 24 | var firstTask = Task.Run(() => 25 | { 26 | Console.WriteLine("First task"); 27 | }); 28 | 29 | var secondTask = Task.Run(() => "Second task"); 30 | 31 | Console.WriteLine("Sync write!"); 32 | 33 | firstTask.Wait(); 34 | 35 | var result = secondTask.Result; 36 | 37 | Console.WriteLine(result); 38 | } 39 | 40 | public static void TaskContinuation() 41 | { 42 | var task = Task 43 | .Run(() => "Result") 44 | .ContinueWith(previousTask => 45 | { 46 | Console.WriteLine(previousTask.Result); 47 | }) 48 | .ContinueWith(previousTask => Task.Delay(2000).Wait()) 49 | .ContinueWith(previousTask => 50 | { 51 | Console.WriteLine("After delay!"); 52 | }); 53 | 54 | task.Wait(); 55 | } 56 | 57 | public static void TaskExceptionsAndStatus() 58 | { 59 | var task = Task 60 | .Run(() => throw new InvalidOperationException("Some exception")) 61 | .ContinueWith(previousTask => 62 | { 63 | if (previousTask.IsFaulted) 64 | { 65 | Console.WriteLine(previousTask.Exception.Message); 66 | } 67 | }) 68 | .ContinueWith(previousTask => 69 | { 70 | if (previousTask.IsCompletedSuccessfully) 71 | { 72 | Console.WriteLine("Done"); 73 | } 74 | }); 75 | 76 | task.Wait(); 77 | } 78 | 79 | public static void MultipleTasksAtTheSameTime() 80 | { 81 | var firstTask = Task 82 | .Run(() => Task.Delay(3000).Wait()) 83 | .ContinueWith(_ => Console.WriteLine("First")); 84 | 85 | var secondTask = Task 86 | .Run(() => Task.Delay(1000).Wait()) 87 | .ContinueWith(_ => Console.WriteLine("Second")); 88 | 89 | var thirdTask = Task 90 | .Run(() => Task.Delay(2000).Wait()) 91 | .ContinueWith(_ => Console.WriteLine("Third")); 92 | 93 | Task.WaitAll(firstTask, secondTask, thirdTask); 94 | } 95 | 96 | public static void AtLeastOneTaskToFinish() 97 | { 98 | Console.WriteLine("You have 5 seconds to solve this: 111 * 111"); 99 | 100 | var inputTask = Task.Run(() => 101 | { 102 | while (true) 103 | { 104 | var input = Console.ReadLine(); 105 | 106 | if (input == "12321") 107 | { 108 | Console.WriteLine("Correct!"); 109 | break; 110 | } 111 | 112 | Console.WriteLine("Wrong answer!"); 113 | } 114 | }); 115 | 116 | var timerTask = Task.Run(() => 117 | { 118 | for (var i = 5; i > 0; i--) 119 | { 120 | Console.WriteLine(i); 121 | 122 | Task.Delay(1000).Wait(); 123 | } 124 | }); 125 | 126 | Task.WaitAny(inputTask, timerTask); 127 | } 128 | 129 | public static void CompletedTaskAndFromResult() 130 | { 131 | while (true) 132 | { 133 | var input = Console.ReadLine(); 134 | 135 | if (input == "end") 136 | { 137 | break; 138 | } 139 | 140 | var task = input switch 141 | { 142 | "delay" => Task 143 | .Delay(2000) 144 | .ContinueWith(_ => Console.WriteLine("Delayed")), 145 | 146 | "print" => Task 147 | .Run(() => Console.WriteLine("Printed!")), 148 | 149 | "throw" => Task 150 | .FromException(new InvalidOperationException("Error")) 151 | .ContinueWith(prev => Console.WriteLine(prev.Exception.Message)), 152 | 153 | "42" => Task 154 | .FromResult(42) 155 | .ContinueWith(prev => Console.WriteLine(prev.Result)), 156 | 157 | _ => Task 158 | .CompletedTask 159 | .ContinueWith(_ => Console.WriteLine("Invalid input!")) 160 | }; 161 | 162 | task.Wait(); 163 | } 164 | } 165 | 166 | public static void DownloadContentAndSaveItToFile() 167 | { 168 | using var httpClient = new HttpClient(); 169 | 170 | var googleTask = httpClient.GetStringAsync("https://google.com"); 171 | 172 | googleTask 173 | .ContinueWith(prevTask => 174 | { 175 | File 176 | .WriteAllTextAsync("google.txt", prevTask.Result) 177 | .Wait(); 178 | }); 179 | 180 | var codeLessonsTask = httpClient.GetStringAsync("http://codelessons.online/"); 181 | 182 | codeLessonsTask 183 | .ContinueWith(prevTask => 184 | { 185 | File 186 | .WriteAllTextAsync("codelessons.txt", prevTask.Result) 187 | .Wait(); 188 | }); 189 | 190 | var myTestedTask = httpClient.GetStringAsync("https://mytestedasp.net"); 191 | 192 | myTestedTask 193 | .ContinueWith(prevTask => 194 | { 195 | File 196 | .WriteAllTextAsync("mytestedaspnet.txt", prevTask.Result) 197 | .Wait(); 198 | }); 199 | 200 | var tasks = new[] 201 | { 202 | googleTask, 203 | codeLessonsTask, 204 | myTestedTask 205 | }; 206 | 207 | Task 208 | .WhenAll(tasks) 209 | .ContinueWith(prevTask => 210 | { 211 | var content = $"{prevTask.Result[0]}{prevTask.Result[1]}{prevTask.Result[2]}"; 212 | 213 | File 214 | .AppendAllTextAsync("downloads.txt", content) 215 | .Wait(); 216 | }) 217 | .Wait(); 218 | } 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /AsyncAwait/5. AsyncAwait/05. AsyncAwait.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | AsyncAwait 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/5. AsyncAwait/Extensions.cs: -------------------------------------------------------------------------------- 1 | namespace AsyncAwait 2 | { 3 | using System; 4 | 5 | public static class Extensions 6 | { 7 | public static void Deconstruct(this T[] items, out T first, out T second, out T third) 8 | { 9 | if (items.Length < 3) 10 | { 11 | throw new InvalidOperationException("Items must be at least 3 to deconstruct them with this method."); 12 | } 13 | 14 | first = items[0]; 15 | second = items[1]; 16 | third = items[2]; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /AsyncAwait/5. AsyncAwait/Program.cs: -------------------------------------------------------------------------------- 1 | namespace AsyncAwait 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Net.Http; 7 | using System.Threading.Tasks; 8 | 9 | public class Program 10 | { 11 | public static async Task Main() 12 | { 13 | await WaitForTask(); 14 | await TaskContinuation(); 15 | await TaskExceptionsAndStatus(); 16 | await MultipleTasksAtTheSameTime(); 17 | await AtLeastOneTaskToFinish(); 18 | await CompletedTaskAndFromResult(); 19 | await DownloadContentAndSaveItToFile(); 20 | 21 | // Bonus 22 | AsyncLambda(); 23 | } 24 | 25 | public static async Task WaitForTask() 26 | { 27 | //var firstTask = Task.Run(() => 28 | //{ 29 | // Console.WriteLine("First task"); 30 | //}); 31 | 32 | //var secondTask = Task.Run(() => "Second task"); 33 | 34 | //Console.WriteLine("Sync write!"); 35 | 36 | //firstTask.Wait(); 37 | 38 | //var result = secondTask.Result; 39 | 40 | //Console.WriteLine(result); 41 | 42 | var firstTask = Task.Run(() => 43 | { 44 | Console.WriteLine("First task"); 45 | }); 46 | 47 | var secondTask = Task.Run(() => "Second task"); 48 | 49 | Console.WriteLine("Sync write!"); 50 | 51 | await firstTask; 52 | 53 | var result = await secondTask; 54 | 55 | Console.WriteLine(result); 56 | } 57 | 58 | public static async Task TaskContinuation() 59 | { 60 | //var task = Task 61 | // .Run(() => "Result") 62 | // .ContinueWith(previousTask => 63 | // { 64 | // Console.WriteLine(previousTask.Result); 65 | // }) 66 | // .ContinueWith(previousTask => Task.Delay(2000).Wait()) 67 | // .ContinueWith(previousTask => 68 | // { 69 | // Console.WriteLine("After delay!"); 70 | // }); 71 | 72 | //task.Wait(); 73 | 74 | Console.WriteLine("Before"); 75 | 76 | var result = await Task.Run(() => "Result"); // 5 seconds, Worker works something else, Call me 77 | 78 | Console.WriteLine(result); 79 | 80 | await Task.Delay(2000); // 2 second, something else, call me 81 | 82 | Console.WriteLine("After delay!"); 83 | } 84 | 85 | public static async Task TaskExceptionsAndStatus() 86 | { 87 | try 88 | { 89 | await Task.Run(() => throw new InvalidOperationException("Some exception")); 90 | } 91 | catch (InvalidOperationException exception) 92 | { 93 | Console.WriteLine(exception.Message); 94 | } 95 | 96 | Console.WriteLine("Done"); 97 | 98 | //var task = Task 99 | // .Run(() => throw new InvalidOperationException("Some exception")) 100 | // .ContinueWith(previousTask => 101 | // { 102 | // if (previousTask.IsFaulted) 103 | // { 104 | // Console.WriteLine(previousTask.Exception.Message); 105 | // } 106 | // }) 107 | // .ContinueWith(previousTask => 108 | // { 109 | // if (previousTask.IsCompletedSuccessfully) 110 | // { 111 | // Console.WriteLine("Done"); 112 | // } 113 | // }); 114 | 115 | //task.Wait(); 116 | } 117 | 118 | public static async Task MultipleTasksAtTheSameTime() 119 | { 120 | var firstTask = Task.Run(async () => 121 | { 122 | await Task.Delay(3000); 123 | Console.WriteLine("First"); 124 | }); 125 | 126 | var secondTask = Task.Run(async () => 127 | { 128 | await Task.Delay(1000); 129 | Console.WriteLine("Second"); 130 | }); 131 | 132 | var thirdTask = Task.Run(async () => 133 | { 134 | await Task.Delay(2000); 135 | Console.WriteLine("Third"); 136 | }); 137 | 138 | await Task.WhenAll(firstTask, secondTask, thirdTask); 139 | 140 | //var firstTask = Task 141 | // .Run(() => Task.Delay(3000).Wait()) 142 | // .ContinueWith(_ => Console.WriteLine("First")); 143 | 144 | //var secondTask = Task 145 | // .Run(() => Task.Delay(1000).Wait()) 146 | // .ContinueWith(_ => Console.WriteLine("Second")); 147 | 148 | //var thirdTask = Task 149 | // .Run(() => Task.Delay(2000).Wait()) 150 | // .ContinueWith(_ => Console.WriteLine("Third")); 151 | 152 | //Task.WaitAll(firstTask, secondTask, thirdTask); 153 | } 154 | 155 | public static async Task AtLeastOneTaskToFinish() 156 | { 157 | Console.WriteLine("You have 5 seconds to solve this: 111 * 111"); 158 | 159 | var inputTask = Task.Run(() => 160 | { 161 | while (true) 162 | { 163 | var input = Console.ReadLine(); 164 | 165 | if (input == "12321") 166 | { 167 | Console.WriteLine("Correct!"); 168 | break; 169 | } 170 | 171 | Console.WriteLine("Wrong answer!"); 172 | } 173 | }); 174 | 175 | var timerTask = Task.Run(async () => 176 | { 177 | for (var i = 5; i > 0; i--) 178 | { 179 | Console.WriteLine(i); 180 | 181 | await Task.Delay(1000); 182 | } 183 | }); 184 | 185 | await Task.WhenAny(inputTask, timerTask); 186 | 187 | //Console.WriteLine("You have 5 seconds to solve this: 111 * 111"); 188 | 189 | //var inputTask = Task.Run(() => 190 | //{ 191 | // while (true) 192 | // { 193 | // var input = Console.ReadLine(); 194 | 195 | // if (input == "12321") 196 | // { 197 | // Console.WriteLine("Correct!"); 198 | // break; 199 | // } 200 | 201 | // Console.WriteLine("Wrong answer!"); 202 | // } 203 | //}); 204 | 205 | //var timerTask = Task.Run(() => 206 | //{ 207 | // for (var i = 5; i > 0; i--) 208 | // { 209 | // Console.WriteLine(i); 210 | 211 | // Task.Delay(1000).Wait(); 212 | // } 213 | //}); 214 | 215 | //Task.WaitAny(inputTask, timerTask); 216 | } 217 | 218 | public static async Task CompletedTaskAndFromResult() 219 | { 220 | while (true) 221 | { 222 | var input = Console.ReadLine(); 223 | 224 | if (input == "end") 225 | { 226 | break; 227 | } 228 | 229 | var task = input switch 230 | { 231 | "delay" => Task 232 | .Delay(2000) 233 | .ContinueWith(_ => Console.WriteLine("Delayed")), 234 | 235 | "print" => Task 236 | .Run(() => Console.WriteLine("Printed!")), 237 | 238 | "throw" => Task 239 | .FromException(new InvalidOperationException("Error")) 240 | .ContinueWith(prev => Console.WriteLine(prev.Exception.Message)), 241 | 242 | "42" => Task 243 | .FromResult(42) 244 | .ContinueWith(prev => Console.WriteLine(prev.Result)), 245 | 246 | _ => Task 247 | .CompletedTask 248 | .ContinueWith(_ => Console.WriteLine("Invalid input!")) 249 | }; 250 | 251 | await task; 252 | } 253 | 254 | //while (true) 255 | //{ 256 | // var input = Console.ReadLine(); 257 | 258 | // if (input == "end") 259 | // { 260 | // break; 261 | // } 262 | 263 | // var task = input switch 264 | // { 265 | // "delay" => Task 266 | // .Delay(2000) 267 | // .ContinueWith(_ => Console.WriteLine("Delayed")), 268 | 269 | // "print" => Task 270 | // .Run(() => Console.WriteLine("Printed!")), 271 | 272 | // "throw" => Task 273 | // .FromException(new InvalidOperationException("Error")) 274 | // .ContinueWith(prev => Console.WriteLine(prev.Exception.Message)), 275 | 276 | // "42" => Task 277 | // .FromResult(42) 278 | // .ContinueWith(prev => Console.WriteLine(prev.Result)), 279 | 280 | // _ => Task 281 | // .CompletedTask 282 | // .ContinueWith(_ => Console.WriteLine("Invalid input!")) 283 | // }; 284 | 285 | // task.Wait(); 286 | //} 287 | } 288 | 289 | public static async Task DownloadContentAndSaveItToFile() 290 | { 291 | using var httpClient = new HttpClient(); 292 | 293 | var googleTask = httpClient.GetStringAsync("https://google.com"); 294 | var codeLessonsTask = httpClient.GetStringAsync("http://codelessons.online/"); 295 | var myTestedTask = httpClient.GetStringAsync("https://mytestedasp.net"); 296 | 297 | var getTasks = new List> 298 | { 299 | googleTask, codeLessonsTask, myTestedTask 300 | }; 301 | 302 | var (google, codeLessons, myTested) = await Task.WhenAll(getTasks); 303 | 304 | var writeFileTasks = new List 305 | { 306 | File.WriteAllTextAsync("google.txt", google), 307 | File.WriteAllTextAsync("codelessons.txt", codeLessons), 308 | File.WriteAllTextAsync("mytestedaspnet.txt", myTested) 309 | }; 310 | 311 | await Task.WhenAll(writeFileTasks); 312 | 313 | var content = $"{google}{codeLessons}{myTested}"; 314 | 315 | await File.AppendAllTextAsync("downloads.txt", content); 316 | 317 | //using var httpClient = new HttpClient(); 318 | 319 | //var googleTask = httpClient 320 | // .GetStringAsync("https://google.com") 321 | // .ContinueWith(prevTask => 322 | // { 323 | // File 324 | // .WriteAllTextAsync("google.txt", prevTask.Result) 325 | // .Wait(); 326 | 327 | // return prevTask.Result; 328 | // }); 329 | 330 | //var codeLessonsTask = httpClient 331 | // .GetStringAsync("http://codelessons.online/") 332 | // .ContinueWith(prevTask => 333 | // { 334 | // File 335 | // .WriteAllTextAsync("codelessons.txt", prevTask.Result) 336 | // .Wait(); 337 | 338 | // return prevTask.Result; 339 | // }); 340 | 341 | //var myTestedTask = httpClient 342 | // .GetStringAsync("https://mytestedasp.net") 343 | // .ContinueWith(prevTask => 344 | // { 345 | // File 346 | // .WriteAllTextAsync("mytestedaspnet.txt", prevTask.Result) 347 | // .Wait(); 348 | 349 | // return prevTask.Result; 350 | // }); 351 | 352 | //var tasks = new[] 353 | //{ 354 | // googleTask, 355 | // codeLessonsTask, 356 | // myTestedTask 357 | //}; 358 | 359 | //Task 360 | // .WhenAll(tasks) 361 | // .ContinueWith(prevTask => 362 | // { 363 | // var content = $"{prevTask.Result[0]}{prevTask.Result[1]}{prevTask.Result[2]}"; 364 | 365 | // File 366 | // .AppendAllTextAsync("downloads.txt", content) 367 | // .Wait(); 368 | // }) 369 | // .Wait(); 370 | } 371 | 372 | public static void AsyncLambda() 373 | { 374 | var list = new List { 1, 2, 3, 4, 5 }; 375 | 376 | list.ForEach(async number => 377 | { 378 | await Task.Run(() => Console.WriteLine(number)); 379 | }); 380 | } 381 | } 382 | } 383 | -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/06. PerformanceExample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | PerformanceExample 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Never 17 | 18 | 19 | Never 20 | 21 | 22 | Never 23 | 24 | 25 | Never 26 | 27 | 28 | Never 29 | 30 | 31 | Never 32 | 33 | 34 | Never 35 | 36 | 37 | Never 38 | 39 | 40 | Never 41 | 42 | 43 | Never 44 | 45 | 46 | Never 47 | 48 | 49 | Never 50 | 51 | 52 | Never 53 | 54 | 55 | Never 56 | 57 | 58 | Never 59 | 60 | 61 | Never 62 | 63 | 64 | Never 65 | 66 | 67 | Never 68 | 69 | 70 | Never 71 | 72 | 73 | Never 74 | 75 | 76 | Never 77 | 78 | 79 | Never 80 | 81 | 82 | Never 83 | 84 | 85 | Never 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/1.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/10.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/11.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/12.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/13.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/14.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/15.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/16.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/17.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/18.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/19.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/2.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/20.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/21.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/22.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/23.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/24.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/3.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/4.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/5.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/6.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/7.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/8.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/9.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/1.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/10.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/11.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/12.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/13.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/14.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/15.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/6. PerformanceExample/Images/MoreThanCpuSync/16.jpg -------------------------------------------------------------------------------- /AsyncAwait/6. PerformanceExample/Program.cs: -------------------------------------------------------------------------------- 1 | namespace PerformanceExample 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | using BenchmarkDotNet.Attributes; 10 | using BenchmarkDotNet.Running; 11 | using SixLabors.ImageSharp; 12 | using SixLabors.ImageSharp.Processing; 13 | 14 | public class Program 15 | { 16 | private const int NumberOfCpus = 12; 17 | 18 | private const string ImagesDirectory = @"C:\Data\Projects\Code It Up\Source\1. C# Async-Await In Detail\6. PerformanceExample\Images"; 19 | private const string CpuSyncDirectory = ImagesDirectory + @"\CpuSync\"; 20 | private const string CpuAsyncDirectory = ImagesDirectory + @"\CpuAsync\"; 21 | private const string CpuAsyncMultipleDirectory = ImagesDirectory + @"\CpuAsyncMultiple\"; 22 | private const string MoreThanCpuSyncDirectory = ImagesDirectory + @"\MoreThanCpuSync\"; 23 | private const string MoreThanCpuAsyncMultipleDirectory = ImagesDirectory + @"\MoreThanCpuAsyncMultiple\"; 24 | 25 | public static async Task Main() 26 | { 27 | //var benchmark = BenchmarkRunner.Run(); 28 | 29 | //Console.WriteLine(benchmark); 30 | 31 | var program = new Program(); 32 | 33 | var stopWatch = Stopwatch.StartNew(); 34 | 35 | program.ResizeCpuSynchronously(); 36 | 37 | Console.WriteLine($"CPU Sync - {stopWatch.Elapsed}"); 38 | 39 | stopWatch = Stopwatch.StartNew(); 40 | 41 | await program.ResizeCpuAsynchronously(); 42 | 43 | Console.WriteLine($"CPU Async - {stopWatch.Elapsed}"); 44 | 45 | stopWatch = Stopwatch.StartNew(); 46 | 47 | await program.ResizeCpuAsynchronouslyMultipleTasks(); 48 | 49 | Console.WriteLine($"CPU Async Multiple Tasks - {stopWatch.Elapsed}"); 50 | 51 | stopWatch = Stopwatch.StartNew(); 52 | 53 | program.ResizeMoreThanCpuSynchronously(); 54 | 55 | Console.WriteLine($"More Than CPU Sync - {stopWatch.Elapsed}"); 56 | 57 | stopWatch = Stopwatch.StartNew(); 58 | 59 | await program.ResizeMoreThanCpuAsynchronouslyMultipleTasks(); 60 | 61 | Console.WriteLine($"More Than CPU Async - {stopWatch.Elapsed}"); 62 | } 63 | 64 | [Benchmark] 65 | public void ResizeCpuSynchronously() 66 | { 67 | var dir = CpuSyncDirectory; 68 | 69 | Directory.CreateDirectory(dir); 70 | 71 | var files = ReadFiles().Take(NumberOfCpus); 72 | 73 | foreach (var file in files) 74 | { 75 | var fileInfo = new FileInfo(file); 76 | 77 | ProcessImage(file, dir + $"{fileInfo.Name}"); 78 | } 79 | 80 | Directory.Delete(dir, true); 81 | } 82 | 83 | [Benchmark] 84 | public async Task ResizeCpuAsynchronously() 85 | { 86 | var dir = CpuAsyncDirectory; 87 | 88 | Directory.CreateDirectory(dir); 89 | 90 | var files = ReadFiles().Take(NumberOfCpus); 91 | 92 | foreach (var file in files) 93 | { 94 | var fileInfo = new FileInfo(file); 95 | 96 | await Task.Run(() => 97 | { 98 | ProcessImage(file, dir + $"{fileInfo.Name}"); 99 | }); 100 | } 101 | 102 | Directory.Delete(dir, true); 103 | } 104 | 105 | [Benchmark] 106 | public async Task ResizeCpuAsynchronouslyMultipleTasks() 107 | { 108 | var dir = CpuAsyncMultipleDirectory; 109 | 110 | Directory.CreateDirectory(dir); 111 | 112 | var files = ReadFiles().Take(NumberOfCpus); 113 | 114 | var tasks = new List(); 115 | 116 | foreach (var file in files) 117 | { 118 | var fileInfo = new FileInfo(file); 119 | 120 | tasks.Add(Task.Run(() => 121 | { 122 | ProcessImage(file, dir + $"{fileInfo.Name}"); 123 | })); 124 | } 125 | 126 | await Task.WhenAll(tasks); 127 | 128 | Directory.Delete(dir, true); 129 | } 130 | 131 | [Benchmark] 132 | public void ResizeMoreThanCpuSynchronously() 133 | { 134 | var dir = MoreThanCpuSyncDirectory; 135 | 136 | Directory.CreateDirectory(dir); 137 | 138 | var files = ReadFiles(); 139 | 140 | foreach (var file in files) 141 | { 142 | var fileInfo = new FileInfo(file); 143 | 144 | ProcessImage(file, dir + $"{fileInfo.Name}"); 145 | } 146 | 147 | Directory.Delete(dir, true); 148 | } 149 | 150 | [Benchmark] 151 | public async Task ResizeMoreThanCpuAsynchronouslyMultipleTasks() 152 | { 153 | var dir = MoreThanCpuAsyncMultipleDirectory; 154 | 155 | Directory.CreateDirectory(dir); 156 | 157 | var files = ReadFiles(); 158 | 159 | var tasks = new List(); 160 | 161 | foreach (var file in files) 162 | { 163 | var fileInfo = new FileInfo(file); 164 | 165 | tasks.Add(Task.Run(() => 166 | { 167 | ProcessImage(file, dir + $"{fileInfo.Name}"); 168 | })); 169 | } 170 | 171 | await Task.WhenAll(tasks); 172 | 173 | Directory.Delete(dir, true); 174 | } 175 | 176 | private static IEnumerable ReadFiles() 177 | => Directory.GetFiles(ImagesDirectory); 178 | 179 | private static void ProcessImage(string inputPath, string outputPath) 180 | { 181 | using var image = Image.Load(inputPath); 182 | 183 | image.Mutate(x => x.Resize(2000, 2000)); 184 | 185 | image.Save(outputPath); 186 | } 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /AsyncAwait/7. Gotchas/07. Gotchas.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | Gotchas 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/7. Gotchas/Program.cs: -------------------------------------------------------------------------------- 1 | namespace Gotchas 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | public class Program 8 | { 9 | public static async Task Main() 10 | { 11 | RunAsyncVoid(); 12 | // AsyncVoidLambda(); // Remove the async and see. 13 | 14 | await NestedTasks(); 15 | } 16 | 17 | public static void RunAsyncVoid() 18 | { 19 | try 20 | { 21 | AsyncVoid(); 22 | } 23 | catch 24 | { 25 | Console.WriteLine("Cannot be caught!"); 26 | } 27 | } 28 | 29 | public static void AsyncVoidLambda() 30 | { 31 | try 32 | { 33 | var list = new List { 1, 2, 3, 4, 5 }; 34 | 35 | list.ForEach(async number => 36 | { 37 | await Task.Run(() => Console.WriteLine(number)); 38 | 39 | throw new InvalidOperationException("In a lambda!"); 40 | }); 41 | } 42 | catch 43 | { 44 | Console.WriteLine("Cannot be caught!"); 45 | } 46 | } 47 | 48 | public static async void AsyncVoid() 49 | { 50 | await Task.Run(() => Console.WriteLine("Message")); 51 | 52 | throw new InvalidOperationException("Error"); 53 | } 54 | 55 | public static async Task NestedTasks() 56 | { 57 | await Task.Run(async () => 58 | { 59 | Console.WriteLine("Before Delay"); 60 | 61 | await Task.Delay(1000); 62 | 63 | Console.WriteLine("After Delay"); 64 | }); 65 | 66 | Console.WriteLine("After Task"); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/08. Deadlock.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | 9 | 10 | 2.0 11 | {040B2F7B-D047-4804-9AA0-61CEB81D9C4A} 12 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 13 | Library 14 | Properties 15 | Deadlock 16 | Deadlock 17 | v4.7.2 18 | false 19 | true 20 | 21 | 44323 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | true 31 | full 32 | false 33 | bin\ 34 | DEBUG;TRACE 35 | prompt 36 | 4 37 | 38 | 39 | true 40 | pdbonly 41 | true 42 | bin\ 43 | TRACE 44 | prompt 45 | 4 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | True 69 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 70 | 71 | 72 | 73 | 74 | 75 | 76 | True 77 | ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll 78 | 79 | 80 | True 81 | ..\packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll 82 | 83 | 84 | ..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll 85 | 86 | 87 | True 88 | ..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll 89 | 90 | 91 | True 92 | ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll 93 | 94 | 95 | True 96 | ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll 97 | 98 | 99 | True 100 | ..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll 101 | 102 | 103 | ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll 104 | 105 | 106 | True 107 | ..\packages\WebGrease.1.6.0\lib\WebGrease.dll 108 | 109 | 110 | True 111 | ..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll 112 | 113 | 114 | 115 | 116 | ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | Global.asax 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | Web.config 154 | 155 | 156 | Web.config 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 10.0 185 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | True 198 | True 199 | 53056 200 | / 201 | https://localhost:44323/ 202 | False 203 | False 204 | 205 | 206 | False 207 | 208 | 209 | 210 | 211 | 212 | 213 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 214 | 215 | 216 | 217 | 223 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Optimization; 3 | 4 | namespace Deadlock 5 | { 6 | public class BundleConfig 7 | { 8 | // For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-{version}.js")); 13 | 14 | bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( 15 | "~/Scripts/jquery.validate*")); 16 | 17 | // Use the development version of Modernizr to develop with and learn from. Then, when you're 18 | // ready for production, use the build tool at https://modernizr.com to pick only the tests you need. 19 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( 20 | "~/Scripts/modernizr-*")); 21 | 22 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 23 | "~/Scripts/bootstrap.js")); 24 | 25 | bundles.Add(new StyleBundle("~/Content/css").Include( 26 | "~/Content/bootstrap.css", 27 | "~/Content/site.css")); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace Deadlock 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace Deadlock 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Content/Site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Set padding to keep content from hitting the edges */ 7 | .body-content { 8 | padding-left: 15px; 9 | padding-right: 15px; 10 | } 11 | 12 | /* Override the default bootstrap behavior where horizontal description lists 13 | will truncate terms that are too long to fit in the left column 14 | */ 15 | .dl-horizontal dt { 16 | white-space: normal; 17 | } 18 | 19 | /* Set width on the form input elements since they're 100% wide by default */ 20 | input, 21 | select, 22 | textarea { 23 | max-width: 280px; 24 | } 25 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Content/bootstrap-theme.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.4.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2019 Twitter, Inc. 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | */.btn-danger,.btn-default,.btn-info,.btn-primary,.btn-success,.btn-warning{text-shadow:0 -1px 0 rgba(0,0,0,.2);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 1px rgba(0,0,0,.075)}.btn-danger.active,.btn-danger:active,.btn-default.active,.btn-default:active,.btn-info.active,.btn-info:active,.btn-primary.active,.btn-primary:active,.btn-success.active,.btn-success:active,.btn-warning.active,.btn-warning:active{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn-danger.disabled,.btn-danger[disabled],.btn-default.disabled,.btn-default[disabled],.btn-info.disabled,.btn-info[disabled],.btn-primary.disabled,.btn-primary[disabled],.btn-success.disabled,.btn-success[disabled],.btn-warning.disabled,.btn-warning[disabled],fieldset[disabled] .btn-danger,fieldset[disabled] .btn-default,fieldset[disabled] .btn-info,fieldset[disabled] .btn-primary,fieldset[disabled] .btn-success,fieldset[disabled] .btn-warning{-webkit-box-shadow:none;box-shadow:none}.btn-danger .badge,.btn-default .badge,.btn-info .badge,.btn-primary .badge,.btn-success .badge,.btn-warning .badge{text-shadow:none}.btn.active,.btn:active{background-image:none}.btn-default{background-image:-webkit-linear-gradient(top,#fff 0,#e0e0e0 100%);background-image:-o-linear-gradient(top,#fff 0,#e0e0e0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fff),to(#e0e0e0));background-image:linear-gradient(to bottom,#fff 0,#e0e0e0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#dbdbdb;text-shadow:0 1px 0 #fff;border-color:#ccc}.btn-default:focus,.btn-default:hover{background-color:#e0e0e0;background-position:0 -15px}.btn-default.active,.btn-default:active{background-color:#e0e0e0;border-color:#dbdbdb}.btn-default.disabled,.btn-default.disabled.active,.btn-default.disabled.focus,.btn-default.disabled:active,.btn-default.disabled:focus,.btn-default.disabled:hover,.btn-default[disabled],.btn-default[disabled].active,.btn-default[disabled].focus,.btn-default[disabled]:active,.btn-default[disabled]:focus,.btn-default[disabled]:hover,fieldset[disabled] .btn-default,fieldset[disabled] .btn-default.active,fieldset[disabled] .btn-default.focus,fieldset[disabled] .btn-default:active,fieldset[disabled] .btn-default:focus,fieldset[disabled] .btn-default:hover{background-color:#e0e0e0;background-image:none}.btn-primary{background-image:-webkit-linear-gradient(top,#337ab7 0,#265a88 100%);background-image:-o-linear-gradient(top,#337ab7 0,#265a88 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#265a88));background-image:linear-gradient(to bottom,#337ab7 0,#265a88 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff265a88', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#245580}.btn-primary:focus,.btn-primary:hover{background-color:#265a88;background-position:0 -15px}.btn-primary.active,.btn-primary:active{background-color:#265a88;border-color:#245580}.btn-primary.disabled,.btn-primary.disabled.active,.btn-primary.disabled.focus,.btn-primary.disabled:active,.btn-primary.disabled:focus,.btn-primary.disabled:hover,.btn-primary[disabled],.btn-primary[disabled].active,.btn-primary[disabled].focus,.btn-primary[disabled]:active,.btn-primary[disabled]:focus,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary,fieldset[disabled] .btn-primary.active,fieldset[disabled] .btn-primary.focus,fieldset[disabled] .btn-primary:active,fieldset[disabled] .btn-primary:focus,fieldset[disabled] .btn-primary:hover{background-color:#265a88;background-image:none}.btn-success{background-image:-webkit-linear-gradient(top,#5cb85c 0,#419641 100%);background-image:-o-linear-gradient(top,#5cb85c 0,#419641 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5cb85c),to(#419641));background-image:linear-gradient(to bottom,#5cb85c 0,#419641 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff419641', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#3e8f3e}.btn-success:focus,.btn-success:hover{background-color:#419641;background-position:0 -15px}.btn-success.active,.btn-success:active{background-color:#419641;border-color:#3e8f3e}.btn-success.disabled,.btn-success.disabled.active,.btn-success.disabled.focus,.btn-success.disabled:active,.btn-success.disabled:focus,.btn-success.disabled:hover,.btn-success[disabled],.btn-success[disabled].active,.btn-success[disabled].focus,.btn-success[disabled]:active,.btn-success[disabled]:focus,.btn-success[disabled]:hover,fieldset[disabled] .btn-success,fieldset[disabled] .btn-success.active,fieldset[disabled] .btn-success.focus,fieldset[disabled] .btn-success:active,fieldset[disabled] .btn-success:focus,fieldset[disabled] .btn-success:hover{background-color:#419641;background-image:none}.btn-info{background-image:-webkit-linear-gradient(top,#5bc0de 0,#2aabd2 100%);background-image:-o-linear-gradient(top,#5bc0de 0,#2aabd2 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5bc0de),to(#2aabd2));background-image:linear-gradient(to bottom,#5bc0de 0,#2aabd2 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2aabd2', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#28a4c9}.btn-info:focus,.btn-info:hover{background-color:#2aabd2;background-position:0 -15px}.btn-info.active,.btn-info:active{background-color:#2aabd2;border-color:#28a4c9}.btn-info.disabled,.btn-info.disabled.active,.btn-info.disabled.focus,.btn-info.disabled:active,.btn-info.disabled:focus,.btn-info.disabled:hover,.btn-info[disabled],.btn-info[disabled].active,.btn-info[disabled].focus,.btn-info[disabled]:active,.btn-info[disabled]:focus,.btn-info[disabled]:hover,fieldset[disabled] .btn-info,fieldset[disabled] .btn-info.active,fieldset[disabled] .btn-info.focus,fieldset[disabled] .btn-info:active,fieldset[disabled] .btn-info:focus,fieldset[disabled] .btn-info:hover{background-color:#2aabd2;background-image:none}.btn-warning{background-image:-webkit-linear-gradient(top,#f0ad4e 0,#eb9316 100%);background-image:-o-linear-gradient(top,#f0ad4e 0,#eb9316 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f0ad4e),to(#eb9316));background-image:linear-gradient(to bottom,#f0ad4e 0,#eb9316 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffeb9316', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#e38d13}.btn-warning:focus,.btn-warning:hover{background-color:#eb9316;background-position:0 -15px}.btn-warning.active,.btn-warning:active{background-color:#eb9316;border-color:#e38d13}.btn-warning.disabled,.btn-warning.disabled.active,.btn-warning.disabled.focus,.btn-warning.disabled:active,.btn-warning.disabled:focus,.btn-warning.disabled:hover,.btn-warning[disabled],.btn-warning[disabled].active,.btn-warning[disabled].focus,.btn-warning[disabled]:active,.btn-warning[disabled]:focus,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning,fieldset[disabled] .btn-warning.active,fieldset[disabled] .btn-warning.focus,fieldset[disabled] .btn-warning:active,fieldset[disabled] .btn-warning:focus,fieldset[disabled] .btn-warning:hover{background-color:#eb9316;background-image:none}.btn-danger{background-image:-webkit-linear-gradient(top,#d9534f 0,#c12e2a 100%);background-image:-o-linear-gradient(top,#d9534f 0,#c12e2a 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9534f),to(#c12e2a));background-image:linear-gradient(to bottom,#d9534f 0,#c12e2a 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc12e2a', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#b92c28}.btn-danger:focus,.btn-danger:hover{background-color:#c12e2a;background-position:0 -15px}.btn-danger.active,.btn-danger:active{background-color:#c12e2a;border-color:#b92c28}.btn-danger.disabled,.btn-danger.disabled.active,.btn-danger.disabled.focus,.btn-danger.disabled:active,.btn-danger.disabled:focus,.btn-danger.disabled:hover,.btn-danger[disabled],.btn-danger[disabled].active,.btn-danger[disabled].focus,.btn-danger[disabled]:active,.btn-danger[disabled]:focus,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger,fieldset[disabled] .btn-danger.active,fieldset[disabled] .btn-danger.focus,fieldset[disabled] .btn-danger:active,fieldset[disabled] .btn-danger:focus,fieldset[disabled] .btn-danger:hover{background-color:#c12e2a;background-image:none}.img-thumbnail,.thumbnail{-webkit-box-shadow:0 1px 2px rgba(0,0,0,.075);box-shadow:0 1px 2px rgba(0,0,0,.075)}.dropdown-menu>li>a:focus,.dropdown-menu>li>a:hover{background-image:-webkit-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-o-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),to(#e8e8e8));background-image:linear-gradient(to bottom,#f5f5f5 0,#e8e8e8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);background-repeat:repeat-x;background-color:#e8e8e8}.dropdown-menu>.active>a,.dropdown-menu>.active>a:focus,.dropdown-menu>.active>a:hover{background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x;background-color:#2e6da4}.navbar-default{background-image:-webkit-linear-gradient(top,#fff 0,#f8f8f8 100%);background-image:-o-linear-gradient(top,#fff 0,#f8f8f8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fff),to(#f8f8f8));background-image:linear-gradient(to bottom,#fff 0,#f8f8f8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 5px rgba(0,0,0,.075);box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 5px rgba(0,0,0,.075)}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.open>a{background-image:-webkit-linear-gradient(top,#dbdbdb 0,#e2e2e2 100%);background-image:-o-linear-gradient(top,#dbdbdb 0,#e2e2e2 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dbdbdb),to(#e2e2e2));background-image:linear-gradient(to bottom,#dbdbdb 0,#e2e2e2 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdbdbdb', endColorstr='#ffe2e2e2', GradientType=0);background-repeat:repeat-x;-webkit-box-shadow:inset 0 3px 9px rgba(0,0,0,.075);box-shadow:inset 0 3px 9px rgba(0,0,0,.075)}.navbar-brand,.navbar-nav>li>a{text-shadow:0 1px 0 rgba(255,255,255,.25)}.navbar-inverse{background-image:-webkit-linear-gradient(top,#3c3c3c 0,#222 100%);background-image:-o-linear-gradient(top,#3c3c3c 0,#222 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#3c3c3c),to(#222));background-image:linear-gradient(to bottom,#3c3c3c 0,#222 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c', endColorstr='#ff222222', GradientType=0);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border-radius:4px}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.open>a{background-image:-webkit-linear-gradient(top,#080808 0,#0f0f0f 100%);background-image:-o-linear-gradient(top,#080808 0,#0f0f0f 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#080808),to(#0f0f0f));background-image:linear-gradient(to bottom,#080808 0,#0f0f0f 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff080808', endColorstr='#ff0f0f0f', GradientType=0);background-repeat:repeat-x;-webkit-box-shadow:inset 0 3px 9px rgba(0,0,0,.25);box-shadow:inset 0 3px 9px rgba(0,0,0,.25)}.navbar-inverse .navbar-brand,.navbar-inverse .navbar-nav>li>a{text-shadow:0 -1px 0 rgba(0,0,0,.25)}.navbar-fixed-bottom,.navbar-fixed-top,.navbar-static-top{border-radius:0}@media (max-width:767px){.navbar .navbar-nav .open .dropdown-menu>.active>a,.navbar .navbar-nav .open .dropdown-menu>.active>a:focus,.navbar .navbar-nav .open .dropdown-menu>.active>a:hover{color:#fff;background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}}.alert{text-shadow:0 1px 0 rgba(255,255,255,.2);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 2px rgba(0,0,0,.05)}.alert-success{background-image:-webkit-linear-gradient(top,#dff0d8 0,#c8e5bc 100%);background-image:-o-linear-gradient(top,#dff0d8 0,#c8e5bc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dff0d8),to(#c8e5bc));background-image:linear-gradient(to bottom,#dff0d8 0,#c8e5bc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0);background-repeat:repeat-x;border-color:#b2dba1}.alert-info{background-image:-webkit-linear-gradient(top,#d9edf7 0,#b9def0 100%);background-image:-o-linear-gradient(top,#d9edf7 0,#b9def0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9edf7),to(#b9def0));background-image:linear-gradient(to bottom,#d9edf7 0,#b9def0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0);background-repeat:repeat-x;border-color:#9acfea}.alert-warning{background-image:-webkit-linear-gradient(top,#fcf8e3 0,#f8efc0 100%);background-image:-o-linear-gradient(top,#fcf8e3 0,#f8efc0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fcf8e3),to(#f8efc0));background-image:linear-gradient(to bottom,#fcf8e3 0,#f8efc0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0);background-repeat:repeat-x;border-color:#f5e79e}.alert-danger{background-image:-webkit-linear-gradient(top,#f2dede 0,#e7c3c3 100%);background-image:-o-linear-gradient(top,#f2dede 0,#e7c3c3 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f2dede),to(#e7c3c3));background-image:linear-gradient(to bottom,#f2dede 0,#e7c3c3 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0);background-repeat:repeat-x;border-color:#dca7a7}.progress{background-image:-webkit-linear-gradient(top,#ebebeb 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#ebebeb 0,#f5f5f5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#ebebeb),to(#f5f5f5));background-image:linear-gradient(to bottom,#ebebeb 0,#f5f5f5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0);background-repeat:repeat-x}.progress-bar{background-image:-webkit-linear-gradient(top,#337ab7 0,#286090 100%);background-image:-o-linear-gradient(top,#337ab7 0,#286090 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#286090));background-image:linear-gradient(to bottom,#337ab7 0,#286090 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff286090', GradientType=0);background-repeat:repeat-x}.progress-bar-success{background-image:-webkit-linear-gradient(top,#5cb85c 0,#449d44 100%);background-image:-o-linear-gradient(top,#5cb85c 0,#449d44 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5cb85c),to(#449d44));background-image:linear-gradient(to bottom,#5cb85c 0,#449d44 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0);background-repeat:repeat-x}.progress-bar-info{background-image:-webkit-linear-gradient(top,#5bc0de 0,#31b0d5 100%);background-image:-o-linear-gradient(top,#5bc0de 0,#31b0d5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5bc0de),to(#31b0d5));background-image:linear-gradient(to bottom,#5bc0de 0,#31b0d5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0);background-repeat:repeat-x}.progress-bar-warning{background-image:-webkit-linear-gradient(top,#f0ad4e 0,#ec971f 100%);background-image:-o-linear-gradient(top,#f0ad4e 0,#ec971f 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f0ad4e),to(#ec971f));background-image:linear-gradient(to bottom,#f0ad4e 0,#ec971f 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0);background-repeat:repeat-x}.progress-bar-danger{background-image:-webkit-linear-gradient(top,#d9534f 0,#c9302c 100%);background-image:-o-linear-gradient(top,#d9534f 0,#c9302c 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9534f),to(#c9302c));background-image:linear-gradient(to bottom,#d9534f 0,#c9302c 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0);background-repeat:repeat-x}.progress-bar-striped{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.list-group{border-radius:4px;-webkit-box-shadow:0 1px 2px rgba(0,0,0,.075);box-shadow:0 1px 2px rgba(0,0,0,.075)}.list-group-item.active,.list-group-item.active:focus,.list-group-item.active:hover{text-shadow:0 -1px 0 #286090;background-image:-webkit-linear-gradient(top,#337ab7 0,#2b669a 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2b669a 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2b669a));background-image:linear-gradient(to bottom,#337ab7 0,#2b669a 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2b669a', GradientType=0);background-repeat:repeat-x;border-color:#2b669a}.list-group-item.active .badge,.list-group-item.active:focus .badge,.list-group-item.active:hover .badge{text-shadow:none}.panel{-webkit-box-shadow:0 1px 2px rgba(0,0,0,.05);box-shadow:0 1px 2px rgba(0,0,0,.05)}.panel-default>.panel-heading{background-image:-webkit-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-o-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),to(#e8e8e8));background-image:linear-gradient(to bottom,#f5f5f5 0,#e8e8e8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);background-repeat:repeat-x}.panel-primary>.panel-heading{background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}.panel-success>.panel-heading{background-image:-webkit-linear-gradient(top,#dff0d8 0,#d0e9c6 100%);background-image:-o-linear-gradient(top,#dff0d8 0,#d0e9c6 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dff0d8),to(#d0e9c6));background-image:linear-gradient(to bottom,#dff0d8 0,#d0e9c6 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffd0e9c6', GradientType=0);background-repeat:repeat-x}.panel-info>.panel-heading{background-image:-webkit-linear-gradient(top,#d9edf7 0,#c4e3f3 100%);background-image:-o-linear-gradient(top,#d9edf7 0,#c4e3f3 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9edf7),to(#c4e3f3));background-image:linear-gradient(to bottom,#d9edf7 0,#c4e3f3 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0);background-repeat:repeat-x}.panel-warning>.panel-heading{background-image:-webkit-linear-gradient(top,#fcf8e3 0,#faf2cc 100%);background-image:-o-linear-gradient(top,#fcf8e3 0,#faf2cc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fcf8e3),to(#faf2cc));background-image:linear-gradient(to bottom,#fcf8e3 0,#faf2cc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fffaf2cc', GradientType=0);background-repeat:repeat-x}.panel-danger>.panel-heading{background-image:-webkit-linear-gradient(top,#f2dede 0,#ebcccc 100%);background-image:-o-linear-gradient(top,#f2dede 0,#ebcccc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f2dede),to(#ebcccc));background-image:linear-gradient(to bottom,#f2dede 0,#ebcccc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffebcccc', GradientType=0);background-repeat:repeat-x}.well{background-image:-webkit-linear-gradient(top,#e8e8e8 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#e8e8e8 0,#f5f5f5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#e8e8e8),to(#f5f5f5));background-image:linear-gradient(to bottom,#e8e8e8 0,#f5f5f5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0);background-repeat:repeat-x;border-color:#dcdcdc;-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.1);box-shadow:inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.1)} 6 | /*# sourceMappingURL=bootstrap-theme.min.css.map */ -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | namespace Deadlock.Controllers 2 | { 3 | using System.Threading.Tasks; 4 | using System.Web.Mvc; 5 | 6 | public class HomeController : Controller 7 | { 8 | public ActionResult Index() => this.View(); 9 | 10 | public async Task AsyncAction() 11 | { 12 | await WaitASecond(); // Non-blocking 13 | 14 | return this.Content("Success"); 15 | } 16 | 17 | public ActionResult SyncAction() 18 | { 19 | WaitASecond().Wait(); 20 | 21 | return this.Content("Success"); 22 | } 23 | 24 | public static async Task WaitASecond() 25 | { 26 | await Task.Delay(1000); // Use .ConfigureAwait(false) to prevent deadlock. 27 | } 28 | 29 | // The SyncAction method calls WaitASecond (within the UI/ASP.NET context). 30 | // WaitASecond starts delaying by calling Task.Delay (still within the context). 31 | // Task.Delay returns an uncompleted Task, indicating the delay is not complete. 32 | // WaitASecond awaits the Task returned by the delay. The context is captured and will be used to continue running the WaitASecond method later. WaitASecond returns an uncompleted Task, indicating that the WaitASecond method is not complete. 33 | // The top-level method synchronously blocks on the Task returned by WaitASecond. This blocks the context thread. 34 | // Eventually, the delay will complete. This completes the Task that was returned by Task.Delay. 35 | // The continuation for WaitASecond is now ready to run, and it waits for the context to be available so it can execute in the context. 36 | // Deadlock. The top-level method is blocking the context thread, waiting for WaitASecond to complete, and WaitASecond is waiting for the context to be free so it can complete. 37 | } 38 | } -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="Deadlock.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Optimization; 7 | using System.Web.Routing; 8 | 9 | namespace Deadlock 10 | { 11 | public class MvcApplication : System.Web.HttpApplication 12 | { 13 | protected void Application_Start() 14 | { 15 | AreaRegistration.RegisterAllAreas(); 16 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 17 | RouteConfig.RegisterRoutes(RouteTable.Routes); 18 | BundleConfig.RegisterBundles(BundleTable.Bundles); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Deadlock")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Deadlock")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("49a4d871-fc4d-4dce-8d9e-d001d11eb090")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Scripts/jquery.validate.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery Validation Plugin - v1.17.0 - 7/29/2017 2 | * https://jqueryvalidation.org/ 3 | * Copyright (c) 2017 Jörn Zaefferer; Licensed MIT */ 4 | !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){a.extend(a.fn,{validate:function(b){if(!this.length)return void(b&&b.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."));var c=a.data(this[0],"validator");return c?c:(this.attr("novalidate","novalidate"),c=new a.validator(b,this[0]),a.data(this[0],"validator",c),c.settings.onsubmit&&(this.on("click.validate",":submit",function(b){c.submitButton=b.currentTarget,a(this).hasClass("cancel")&&(c.cancelSubmit=!0),void 0!==a(this).attr("formnovalidate")&&(c.cancelSubmit=!0)}),this.on("submit.validate",function(b){function d(){var d,e;return c.submitButton&&(c.settings.submitHandler||c.formSubmitted)&&(d=a("").attr("name",c.submitButton.name).val(a(c.submitButton).val()).appendTo(c.currentForm)),!c.settings.submitHandler||(e=c.settings.submitHandler.call(c,c.currentForm,b),d&&d.remove(),void 0!==e&&e)}return c.settings.debug&&b.preventDefault(),c.cancelSubmit?(c.cancelSubmit=!1,d()):c.form()?c.pendingRequest?(c.formSubmitted=!0,!1):d():(c.focusInvalid(),!1)})),c)},valid:function(){var b,c,d;return a(this[0]).is("form")?b=this.validate().form():(d=[],b=!0,c=a(this[0].form).validate(),this.each(function(){b=c.element(this)&&b,b||(d=d.concat(c.errorList))}),c.errorList=d),b},rules:function(b,c){var d,e,f,g,h,i,j=this[0];if(null!=j&&(!j.form&&j.hasAttribute("contenteditable")&&(j.form=this.closest("form")[0],j.name=this.attr("name")),null!=j.form)){if(b)switch(d=a.data(j.form,"validator").settings,e=d.rules,f=a.validator.staticRules(j),b){case"add":a.extend(f,a.validator.normalizeRule(c)),delete f.messages,e[j.name]=f,c.messages&&(d.messages[j.name]=a.extend(d.messages[j.name],c.messages));break;case"remove":return c?(i={},a.each(c.split(/\s/),function(a,b){i[b]=f[b],delete f[b]}),i):(delete e[j.name],f)}return g=a.validator.normalizeRules(a.extend({},a.validator.classRules(j),a.validator.attributeRules(j),a.validator.dataRules(j),a.validator.staticRules(j)),j),g.required&&(h=g.required,delete g.required,g=a.extend({required:h},g)),g.remote&&(h=g.remote,delete g.remote,g=a.extend(g,{remote:h})),g}}}),a.extend(a.expr.pseudos||a.expr[":"],{blank:function(b){return!a.trim(""+a(b).val())},filled:function(b){var c=a(b).val();return null!==c&&!!a.trim(""+c)},unchecked:function(b){return!a(b).prop("checked")}}),a.validator=function(b,c){this.settings=a.extend(!0,{},a.validator.defaults,b),this.currentForm=c,this.init()},a.validator.format=function(b,c){return 1===arguments.length?function(){var c=a.makeArray(arguments);return c.unshift(b),a.validator.format.apply(this,c)}:void 0===c?b:(arguments.length>2&&c.constructor!==Array&&(c=a.makeArray(arguments).slice(1)),c.constructor!==Array&&(c=[c]),a.each(c,function(a,c){b=b.replace(new RegExp("\\{"+a+"\\}","g"),function(){return c})}),b)},a.extend(a.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",pendingClass:"pending",validClass:"valid",errorElement:"label",focusCleanup:!1,focusInvalid:!0,errorContainer:a([]),errorLabelContainer:a([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(a){this.lastActive=a,this.settings.focusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass),this.hideThese(this.errorsFor(a)))},onfocusout:function(a){this.checkable(a)||!(a.name in this.submitted)&&this.optional(a)||this.element(a)},onkeyup:function(b,c){var d=[16,17,18,20,35,36,37,38,39,40,45,144,225];9===c.which&&""===this.elementValue(b)||a.inArray(c.keyCode,d)!==-1||(b.name in this.submitted||b.name in this.invalid)&&this.element(b)},onclick:function(a){a.name in this.submitted?this.element(a):a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).addClass(c).removeClass(d):a(b).addClass(c).removeClass(d)},unhighlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).removeClass(c).addClass(d):a(b).removeClass(c).addClass(d)}},setDefaults:function(b){a.extend(a.validator.defaults,b)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",equalTo:"Please enter the same value again.",maxlength:a.validator.format("Please enter no more than {0} characters."),minlength:a.validator.format("Please enter at least {0} characters."),rangelength:a.validator.format("Please enter a value between {0} and {1} characters long."),range:a.validator.format("Please enter a value between {0} and {1}."),max:a.validator.format("Please enter a value less than or equal to {0}."),min:a.validator.format("Please enter a value greater than or equal to {0}."),step:a.validator.format("Please enter a multiple of {0}.")},autoCreateRanges:!1,prototype:{init:function(){function b(b){!this.form&&this.hasAttribute("contenteditable")&&(this.form=a(this).closest("form")[0],this.name=a(this).attr("name"));var c=a.data(this.form,"validator"),d="on"+b.type.replace(/^validate/,""),e=c.settings;e[d]&&!a(this).is(e.ignore)&&e[d].call(c,this,b)}this.labelContainer=a(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||a(this.currentForm),this.containers=a(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var c,d=this.groups={};a.each(this.settings.groups,function(b,c){"string"==typeof c&&(c=c.split(/\s/)),a.each(c,function(a,c){d[c]=b})}),c=this.settings.rules,a.each(c,function(b,d){c[b]=a.validator.normalizeRule(d)}),a(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], [type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], [type='radio'], [type='checkbox'], [contenteditable], [type='button']",b).on("click.validate","select, option, [type='radio'], [type='checkbox']",b),this.settings.invalidHandler&&a(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),a.extend(this.submitted,this.errorMap),this.invalid=a.extend({},this.errorMap),this.valid()||a(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(b){var c,d,e=this.clean(b),f=this.validationTargetFor(e),g=this,h=!0;return void 0===f?delete this.invalid[e.name]:(this.prepareElement(f),this.currentElements=a(f),d=this.groups[f.name],d&&a.each(this.groups,function(a,b){b===d&&a!==f.name&&(e=g.validationTargetFor(g.clean(g.findByName(a))),e&&e.name in g.invalid&&(g.currentElements.push(e),h=g.check(e)&&h))}),c=this.check(f)!==!1,h=h&&c,c?this.invalid[f.name]=!1:this.invalid[f.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),a(b).attr("aria-invalid",!c)),h},showErrors:function(b){if(b){var c=this;a.extend(this.errorMap,b),this.errorList=a.map(this.errorMap,function(a,b){return{message:a,element:c.findByName(b)[0]}}),this.successList=a.grep(this.successList,function(a){return!(a.name in b)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){a.fn.resetForm&&a(this.currentForm).resetForm(),this.invalid={},this.submitted={},this.prepareForm(),this.hideErrors();var b=this.elements().removeData("previousValue").removeAttr("aria-invalid");this.resetElements(b)},resetElements:function(a){var b;if(this.settings.unhighlight)for(b=0;a[b];b++)this.settings.unhighlight.call(this,a[b],this.settings.errorClass,""),this.findByName(a[b].name).removeClass(this.settings.validClass);else a.removeClass(this.settings.errorClass).removeClass(this.settings.validClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b,c=0;for(b in a)void 0!==a[b]&&null!==a[b]&&a[b]!==!1&&c++;return c},hideErrors:function(){this.hideThese(this.toHide)},hideThese:function(a){a.not(this.containers).text(""),this.addWrapper(a).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{a(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(b){}},findLastActive:function(){var b=this.lastActive;return b&&1===a.grep(this.errorList,function(a){return a.element.name===b.name}).length&&b},elements:function(){var b=this,c={};return a(this.currentForm).find("input, select, textarea, [contenteditable]").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter(function(){var d=this.name||a(this).attr("name");return!d&&b.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.hasAttribute("contenteditable")&&(this.form=a(this).closest("form")[0],this.name=d),!(d in c||!b.objectLength(a(this).rules()))&&(c[d]=!0,!0)})},clean:function(b){return a(b)[0]},errors:function(){var b=this.settings.errorClass.split(" ").join(".");return a(this.settings.errorElement+"."+b,this.errorContext)},resetInternals:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=a([]),this.toHide=a([])},reset:function(){this.resetInternals(),this.currentElements=a([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(a){this.reset(),this.toHide=this.errorsFor(a)},elementValue:function(b){var c,d,e=a(b),f=b.type;return"radio"===f||"checkbox"===f?this.findByName(b.name).filter(":checked").val():"number"===f&&"undefined"!=typeof b.validity?b.validity.badInput?"NaN":e.val():(c=b.hasAttribute("contenteditable")?e.text():e.val(),"file"===f?"C:\\fakepath\\"===c.substr(0,12)?c.substr(12):(d=c.lastIndexOf("/"),d>=0?c.substr(d+1):(d=c.lastIndexOf("\\"),d>=0?c.substr(d+1):c)):"string"==typeof c?c.replace(/\r/g,""):c)},check:function(b){b=this.validationTargetFor(this.clean(b));var c,d,e,f,g=a(b).rules(),h=a.map(g,function(a,b){return b}).length,i=!1,j=this.elementValue(b);if("function"==typeof g.normalizer?f=g.normalizer:"function"==typeof this.settings.normalizer&&(f=this.settings.normalizer),f){if(j=f.call(b,j),"string"!=typeof j)throw new TypeError("The normalizer should return a string value.");delete g.normalizer}for(d in g){e={method:d,parameters:g[d]};try{if(c=a.validator.methods[d].call(this,j,b,e.parameters),"dependency-mismatch"===c&&1===h){i=!0;continue}if(i=!1,"pending"===c)return void(this.toHide=this.toHide.not(this.errorsFor(b)));if(!c)return this.formatAndAdd(b,e),!1}catch(k){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+b.id+", check the '"+e.method+"' method.",k),k instanceof TypeError&&(k.message+=". Exception occurred when checking element "+b.id+", check the '"+e.method+"' method."),k}}if(!i)return this.objectLength(g)&&this.successList.push(b),!0},customDataMessage:function(b,c){return a(b).data("msg"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase())||a(b).data("msg")},customMessage:function(a,b){var c=this.settings.messages[a];return c&&(c.constructor===String?c:c[b])},findDefined:function(){for(var a=0;aWarning: No message defined for "+b.name+""),e=/\$?\{(\d+)\}/g;return"function"==typeof d?d=d.call(this,c.parameters,b):e.test(d)&&(d=a.validator.format(d.replace(e,"{$1}"),c.parameters)),d},formatAndAdd:function(a,b){var c=this.defaultMessage(a,b);this.errorList.push({message:c,element:a,method:b.method}),this.errorMap[a.name]=c,this.submitted[a.name]=c},addWrapper:function(a){return this.settings.wrapper&&(a=a.add(a.parent(this.settings.wrapper))),a},defaultShowErrors:function(){var a,b,c;for(a=0;this.errorList[a];a++)c=this.errorList[a],this.settings.highlight&&this.settings.highlight.call(this,c.element,this.settings.errorClass,this.settings.validClass),this.showLabel(c.element,c.message);if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);if(this.settings.unhighlight)for(a=0,b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return a(this.errorList).map(function(){return this.element})},showLabel:function(b,c){var d,e,f,g,h=this.errorsFor(b),i=this.idOrName(b),j=a(b).attr("aria-describedby");h.length?(h.removeClass(this.settings.validClass).addClass(this.settings.errorClass),h.html(c)):(h=a("<"+this.settings.errorElement+">").attr("id",i+"-error").addClass(this.settings.errorClass).html(c||""),d=h,this.settings.wrapper&&(d=h.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.length?this.labelContainer.append(d):this.settings.errorPlacement?this.settings.errorPlacement.call(this,d,a(b)):d.insertAfter(b),h.is("label")?h.attr("for",i):0===h.parents("label[for='"+this.escapeCssMeta(i)+"']").length&&(f=h.attr("id"),j?j.match(new RegExp("\\b"+this.escapeCssMeta(f)+"\\b"))||(j+=" "+f):j=f,a(b).attr("aria-describedby",j),e=this.groups[b.name],e&&(g=this,a.each(g.groups,function(b,c){c===e&&a("[name='"+g.escapeCssMeta(b)+"']",g.currentForm).attr("aria-describedby",h.attr("id"))})))),!c&&this.settings.success&&(h.text(""),"string"==typeof this.settings.success?h.addClass(this.settings.success):this.settings.success(h,b)),this.toShow=this.toShow.add(h)},errorsFor:function(b){var c=this.escapeCssMeta(this.idOrName(b)),d=a(b).attr("aria-describedby"),e="label[for='"+c+"'], label[for='"+c+"'] *";return d&&(e=e+", #"+this.escapeCssMeta(d).replace(/\s+/g,", #")),this.errors().filter(e)},escapeCssMeta:function(a){return a.replace(/([\\!"#$%&'()*+,.\/:;<=>?@\[\]^`{|}~])/g,"\\$1")},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(b){return this.checkable(b)&&(b=this.findByName(b.name)),a(b).not(this.settings.ignore)[0]},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(b){return a(this.currentForm).find("[name='"+this.escapeCssMeta(b)+"']")},getLength:function(b,c){switch(c.nodeName.toLowerCase()){case"select":return a("option:selected",c).length;case"input":if(this.checkable(c))return this.findByName(c.name).filter(":checked").length}return b.length},depend:function(a,b){return!this.dependTypes[typeof a]||this.dependTypes[typeof a](a,b)},dependTypes:{"boolean":function(a){return a},string:function(b,c){return!!a(b,c.form).length},"function":function(a,b){return a(b)}},optional:function(b){var c=this.elementValue(b);return!a.validator.methods.required.call(this,c,b)&&"dependency-mismatch"},startRequest:function(b){this.pending[b.name]||(this.pendingRequest++,a(b).addClass(this.settings.pendingClass),this.pending[b.name]=!0)},stopRequest:function(b,c){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[b.name],a(b).removeClass(this.settings.pendingClass),c&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(a(this.currentForm).submit(),this.submitButton&&a("input:hidden[name='"+this.submitButton.name+"']",this.currentForm).remove(),this.formSubmitted=!1):!c&&0===this.pendingRequest&&this.formSubmitted&&(a(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(b,c){return c="string"==typeof c&&c||"remote",a.data(b,"previousValue")||a.data(b,"previousValue",{old:null,valid:!0,message:this.defaultMessage(b,{method:c})})},destroy:function(){this.resetForm(),a(this.currentForm).off(".validate").removeData("validator").find(".validate-equalTo-blur").off(".validate-equalTo").removeClass("validate-equalTo-blur")}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(b,c){b.constructor===String?this.classRuleSettings[b]=c:a.extend(this.classRuleSettings,b)},classRules:function(b){var c={},d=a(b).attr("class");return d&&a.each(d.split(" "),function(){this in a.validator.classRuleSettings&&a.extend(c,a.validator.classRuleSettings[this])}),c},normalizeAttributeRule:function(a,b,c,d){/min|max|step/.test(c)&&(null===b||/number|range|text/.test(b))&&(d=Number(d),isNaN(d)&&(d=void 0)),d||0===d?a[c]=d:b===c&&"range"!==b&&(a[c]=!0)},attributeRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)"required"===c?(d=b.getAttribute(c),""===d&&(d=!0),d=!!d):d=f.attr(c),this.normalizeAttributeRule(e,g,c,d);return e.maxlength&&/-1|2147483647|524288/.test(e.maxlength)&&delete e.maxlength,e},dataRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)d=f.data("rule"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase()),this.normalizeAttributeRule(e,g,c,d);return e},staticRules:function(b){var c={},d=a.data(b.form,"validator");return d.settings.rules&&(c=a.validator.normalizeRule(d.settings.rules[b.name])||{}),c},normalizeRules:function(b,c){return a.each(b,function(d,e){if(e===!1)return void delete b[d];if(e.param||e.depends){var f=!0;switch(typeof e.depends){case"string":f=!!a(e.depends,c.form).length;break;case"function":f=e.depends.call(c,c)}f?b[d]=void 0===e.param||e.param:(a.data(c.form,"validator").resetElements(a(c)),delete b[d])}}),a.each(b,function(d,e){b[d]=a.isFunction(e)&&"normalizer"!==d?e(c):e}),a.each(["minlength","maxlength"],function(){b[this]&&(b[this]=Number(b[this]))}),a.each(["rangelength","range"],function(){var c;b[this]&&(a.isArray(b[this])?b[this]=[Number(b[this][0]),Number(b[this][1])]:"string"==typeof b[this]&&(c=b[this].replace(/[\[\]]/g,"").split(/[\s,]+/),b[this]=[Number(c[0]),Number(c[1])]))}),a.validator.autoCreateRanges&&(null!=b.min&&null!=b.max&&(b.range=[b.min,b.max],delete b.min,delete b.max),null!=b.minlength&&null!=b.maxlength&&(b.rangelength=[b.minlength,b.maxlength],delete b.minlength,delete b.maxlength)),b},normalizeRule:function(b){if("string"==typeof b){var c={};a.each(b.split(/\s/),function(){c[this]=!0}),b=c}return b},addMethod:function(b,c,d){a.validator.methods[b]=c,a.validator.messages[b]=void 0!==d?d:a.validator.messages[b],c.length<3&&a.validator.addClassRules(b,a.validator.normalizeRule(b))},methods:{required:function(b,c,d){if(!this.depend(d,c))return"dependency-mismatch";if("select"===c.nodeName.toLowerCase()){var e=a(c).val();return e&&e.length>0}return this.checkable(c)?this.getLength(b,c)>0:b.length>0},email:function(a,b){return this.optional(b)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(a)},url:function(a,b){return this.optional(b)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[\/?#]\S*)?$/i.test(a)},date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a).toString())},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(a)},number:function(a,b){return this.optional(b)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},minlength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||e>=d},maxlength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||e<=d},rangelength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||e>=d[0]&&e<=d[1]},min:function(a,b,c){return this.optional(b)||a>=c},max:function(a,b,c){return this.optional(b)||a<=c},range:function(a,b,c){return this.optional(b)||a>=c[0]&&a<=c[1]},step:function(b,c,d){var e,f=a(c).attr("type"),g="Step attribute on input type "+f+" is not supported.",h=["text","number","range"],i=new RegExp("\\b"+f+"\\b"),j=f&&!i.test(h.join()),k=function(a){var b=(""+a).match(/(?:\.(\d+))?$/);return b&&b[1]?b[1].length:0},l=function(a){return Math.round(a*Math.pow(10,e))},m=!0;if(j)throw new Error(g);return e=k(d),(k(b)>e||l(b)%l(d)!==0)&&(m=!1),this.optional(c)||m},equalTo:function(b,c,d){var e=a(d);return this.settings.onfocusout&&e.not(".validate-equalTo-blur").length&&e.addClass("validate-equalTo-blur").on("blur.validate-equalTo",function(){a(c).valid()}),b===e.val()},remote:function(b,c,d,e){if(this.optional(c))return"dependency-mismatch";e="string"==typeof e&&e||"remote";var f,g,h,i=this.previousValue(c,e);return this.settings.messages[c.name]||(this.settings.messages[c.name]={}),i.originalMessage=i.originalMessage||this.settings.messages[c.name][e],this.settings.messages[c.name][e]=i.message,d="string"==typeof d&&{url:d}||d,h=a.param(a.extend({data:b},d.data)),i.old===h?i.valid:(i.old=h,f=this,this.startRequest(c),g={},g[c.name]=b,a.ajax(a.extend(!0,{mode:"abort",port:"validate"+c.name,dataType:"json",data:g,context:f.currentForm,success:function(a){var d,g,h,j=a===!0||"true"===a;f.settings.messages[c.name][e]=i.originalMessage,j?(h=f.formSubmitted,f.resetInternals(),f.toHide=f.errorsFor(c),f.formSubmitted=h,f.successList.push(c),f.invalid[c.name]=!1,f.showErrors()):(d={},g=a||f.defaultMessage(c,{method:e,parameters:b}),d[c.name]=i.message=g,f.invalid[c.name]=!0,f.showErrors(d)),i.valid=j,f.stopRequest(c,j)}},d)),"pending")}}});var b,c={};return a.ajaxPrefilter?a.ajaxPrefilter(function(a,b,d){var e=a.port;"abort"===a.mode&&(c[e]&&c[e].abort(),c[e]=d)}):(b=a.ajax,a.ajax=function(d){var e=("mode"in d?d:a.ajaxSettings).mode,f=("port"in d?d:a.ajaxSettings).port;return"abort"===e?(c[f]&&c[f].abort(),c[f]=b.apply(this,arguments),c[f]):b.apply(this,arguments)}),a}); -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Scripts/jquery.validate.unobtrusive.js: -------------------------------------------------------------------------------- 1 | // Unobtrusive validation support library for jQuery and jQuery Validate 2 | // Copyright (c) .NET Foundation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 4 | // @version v3.2.11 5 | 6 | /*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */ 7 | /*global document: false, jQuery: false */ 8 | 9 | (function (factory) { 10 | if (typeof define === 'function' && define.amd) { 11 | // AMD. Register as an anonymous module. 12 | define("jquery.validate.unobtrusive", ['jquery-validation'], factory); 13 | } else if (typeof module === 'object' && module.exports) { 14 | // CommonJS-like environments that support module.exports 15 | module.exports = factory(require('jquery-validation')); 16 | } else { 17 | // Browser global 18 | jQuery.validator.unobtrusive = factory(jQuery); 19 | } 20 | }(function ($) { 21 | var $jQval = $.validator, 22 | adapters, 23 | data_validation = "unobtrusiveValidation"; 24 | 25 | function setValidationValues(options, ruleName, value) { 26 | options.rules[ruleName] = value; 27 | if (options.message) { 28 | options.messages[ruleName] = options.message; 29 | } 30 | } 31 | 32 | function splitAndTrim(value) { 33 | return value.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g); 34 | } 35 | 36 | function escapeAttributeValue(value) { 37 | // As mentioned on http://api.jquery.com/category/selectors/ 38 | return value.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1"); 39 | } 40 | 41 | function getModelPrefix(fieldName) { 42 | return fieldName.substr(0, fieldName.lastIndexOf(".") + 1); 43 | } 44 | 45 | function appendModelPrefix(value, prefix) { 46 | if (value.indexOf("*.") === 0) { 47 | value = value.replace("*.", prefix); 48 | } 49 | return value; 50 | } 51 | 52 | function onError(error, inputElement) { // 'this' is the form element 53 | var container = $(this).find("[data-valmsg-for='" + escapeAttributeValue(inputElement[0].name) + "']"), 54 | replaceAttrValue = container.attr("data-valmsg-replace"), 55 | replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null; 56 | 57 | container.removeClass("field-validation-valid").addClass("field-validation-error"); 58 | error.data("unobtrusiveContainer", container); 59 | 60 | if (replace) { 61 | container.empty(); 62 | error.removeClass("input-validation-error").appendTo(container); 63 | } 64 | else { 65 | error.hide(); 66 | } 67 | } 68 | 69 | function onErrors(event, validator) { // 'this' is the form element 70 | var container = $(this).find("[data-valmsg-summary=true]"), 71 | list = container.find("ul"); 72 | 73 | if (list && list.length && validator.errorList.length) { 74 | list.empty(); 75 | container.addClass("validation-summary-errors").removeClass("validation-summary-valid"); 76 | 77 | $.each(validator.errorList, function () { 78 | $("
  • ").html(this.message).appendTo(list); 79 | }); 80 | } 81 | } 82 | 83 | function onSuccess(error) { // 'this' is the form element 84 | var container = error.data("unobtrusiveContainer"); 85 | 86 | if (container) { 87 | var replaceAttrValue = container.attr("data-valmsg-replace"), 88 | replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) : null; 89 | 90 | container.addClass("field-validation-valid").removeClass("field-validation-error"); 91 | error.removeData("unobtrusiveContainer"); 92 | 93 | if (replace) { 94 | container.empty(); 95 | } 96 | } 97 | } 98 | 99 | function onReset(event) { // 'this' is the form element 100 | var $form = $(this), 101 | key = '__jquery_unobtrusive_validation_form_reset'; 102 | if ($form.data(key)) { 103 | return; 104 | } 105 | // Set a flag that indicates we're currently resetting the form. 106 | $form.data(key, true); 107 | try { 108 | $form.data("validator").resetForm(); 109 | } finally { 110 | $form.removeData(key); 111 | } 112 | 113 | $form.find(".validation-summary-errors") 114 | .addClass("validation-summary-valid") 115 | .removeClass("validation-summary-errors"); 116 | $form.find(".field-validation-error") 117 | .addClass("field-validation-valid") 118 | .removeClass("field-validation-error") 119 | .removeData("unobtrusiveContainer") 120 | .find(">*") // If we were using valmsg-replace, get the underlying error 121 | .removeData("unobtrusiveContainer"); 122 | } 123 | 124 | function validationInfo(form) { 125 | var $form = $(form), 126 | result = $form.data(data_validation), 127 | onResetProxy = $.proxy(onReset, form), 128 | defaultOptions = $jQval.unobtrusive.options || {}, 129 | execInContext = function (name, args) { 130 | var func = defaultOptions[name]; 131 | func && $.isFunction(func) && func.apply(form, args); 132 | }; 133 | 134 | if (!result) { 135 | result = { 136 | options: { // options structure passed to jQuery Validate's validate() method 137 | errorClass: defaultOptions.errorClass || "input-validation-error", 138 | errorElement: defaultOptions.errorElement || "span", 139 | errorPlacement: function () { 140 | onError.apply(form, arguments); 141 | execInContext("errorPlacement", arguments); 142 | }, 143 | invalidHandler: function () { 144 | onErrors.apply(form, arguments); 145 | execInContext("invalidHandler", arguments); 146 | }, 147 | messages: {}, 148 | rules: {}, 149 | success: function () { 150 | onSuccess.apply(form, arguments); 151 | execInContext("success", arguments); 152 | } 153 | }, 154 | attachValidation: function () { 155 | $form 156 | .off("reset." + data_validation, onResetProxy) 157 | .on("reset." + data_validation, onResetProxy) 158 | .validate(this.options); 159 | }, 160 | validate: function () { // a validation function that is called by unobtrusive Ajax 161 | $form.validate(); 162 | return $form.valid(); 163 | } 164 | }; 165 | $form.data(data_validation, result); 166 | } 167 | 168 | return result; 169 | } 170 | 171 | $jQval.unobtrusive = { 172 | adapters: [], 173 | 174 | parseElement: function (element, skipAttach) { 175 | /// 176 | /// Parses a single HTML element for unobtrusive validation attributes. 177 | /// 178 | /// The HTML element to be parsed. 179 | /// [Optional] true to skip attaching the 180 | /// validation to the form. If parsing just this single element, you should specify true. 181 | /// If parsing several elements, you should specify false, and manually attach the validation 182 | /// to the form when you are finished. The default is false. 183 | var $element = $(element), 184 | form = $element.parents("form")[0], 185 | valInfo, rules, messages; 186 | 187 | if (!form) { // Cannot do client-side validation without a form 188 | return; 189 | } 190 | 191 | valInfo = validationInfo(form); 192 | valInfo.options.rules[element.name] = rules = {}; 193 | valInfo.options.messages[element.name] = messages = {}; 194 | 195 | $.each(this.adapters, function () { 196 | var prefix = "data-val-" + this.name, 197 | message = $element.attr(prefix), 198 | paramValues = {}; 199 | 200 | if (message !== undefined) { // Compare against undefined, because an empty message is legal (and falsy) 201 | prefix += "-"; 202 | 203 | $.each(this.params, function () { 204 | paramValues[this] = $element.attr(prefix + this); 205 | }); 206 | 207 | this.adapt({ 208 | element: element, 209 | form: form, 210 | message: message, 211 | params: paramValues, 212 | rules: rules, 213 | messages: messages 214 | }); 215 | } 216 | }); 217 | 218 | $.extend(rules, { "__dummy__": true }); 219 | 220 | if (!skipAttach) { 221 | valInfo.attachValidation(); 222 | } 223 | }, 224 | 225 | parse: function (selector) { 226 | /// 227 | /// Parses all the HTML elements in the specified selector. It looks for input elements decorated 228 | /// with the [data-val=true] attribute value and enables validation according to the data-val-* 229 | /// attribute values. 230 | /// 231 | /// Any valid jQuery selector. 232 | 233 | // $forms includes all forms in selector's DOM hierarchy (parent, children and self) that have at least one 234 | // element with data-val=true 235 | var $selector = $(selector), 236 | $forms = $selector.parents() 237 | .addBack() 238 | .filter("form") 239 | .add($selector.find("form")) 240 | .has("[data-val=true]"); 241 | 242 | $selector.find("[data-val=true]").each(function () { 243 | $jQval.unobtrusive.parseElement(this, true); 244 | }); 245 | 246 | $forms.each(function () { 247 | var info = validationInfo(this); 248 | if (info) { 249 | info.attachValidation(); 250 | } 251 | }); 252 | } 253 | }; 254 | 255 | adapters = $jQval.unobtrusive.adapters; 256 | 257 | adapters.add = function (adapterName, params, fn) { 258 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation. 259 | /// The name of the adapter to be added. This matches the name used 260 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 261 | /// [Optional] An array of parameter names (strings) that will 262 | /// be extracted from the data-val-nnnn-mmmm HTML attributes (where nnnn is the adapter name, and 263 | /// mmmm is the parameter name). 264 | /// The function to call, which adapts the values from the HTML 265 | /// attributes into jQuery Validate rules and/or messages. 266 | /// 267 | if (!fn) { // Called with no params, just a function 268 | fn = params; 269 | params = []; 270 | } 271 | this.push({ name: adapterName, params: params, adapt: fn }); 272 | return this; 273 | }; 274 | 275 | adapters.addBool = function (adapterName, ruleName) { 276 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 277 | /// the jQuery Validate validation rule has no parameter values. 278 | /// The name of the adapter to be added. This matches the name used 279 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 280 | /// [Optional] The name of the jQuery Validate rule. If not provided, the value 281 | /// of adapterName will be used instead. 282 | /// 283 | return this.add(adapterName, function (options) { 284 | setValidationValues(options, ruleName || adapterName, true); 285 | }); 286 | }; 287 | 288 | adapters.addMinMax = function (adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute) { 289 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 290 | /// the jQuery Validate validation has three potential rules (one for min-only, one for max-only, and 291 | /// one for min-and-max). The HTML parameters are expected to be named -min and -max. 292 | /// The name of the adapter to be added. This matches the name used 293 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 294 | /// The name of the jQuery Validate rule to be used when you only 295 | /// have a minimum value. 296 | /// The name of the jQuery Validate rule to be used when you only 297 | /// have a maximum value. 298 | /// The name of the jQuery Validate rule to be used when you 299 | /// have both a minimum and maximum value. 300 | /// [Optional] The name of the HTML attribute that 301 | /// contains the minimum value. The default is "min". 302 | /// [Optional] The name of the HTML attribute that 303 | /// contains the maximum value. The default is "max". 304 | /// 305 | return this.add(adapterName, [minAttribute || "min", maxAttribute || "max"], function (options) { 306 | var min = options.params.min, 307 | max = options.params.max; 308 | 309 | if (min && max) { 310 | setValidationValues(options, minMaxRuleName, [min, max]); 311 | } 312 | else if (min) { 313 | setValidationValues(options, minRuleName, min); 314 | } 315 | else if (max) { 316 | setValidationValues(options, maxRuleName, max); 317 | } 318 | }); 319 | }; 320 | 321 | adapters.addSingleVal = function (adapterName, attribute, ruleName) { 322 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 323 | /// the jQuery Validate validation rule has a single value. 324 | /// The name of the adapter to be added. This matches the name used 325 | /// in the data-val-nnnn HTML attribute(where nnnn is the adapter name). 326 | /// [Optional] The name of the HTML attribute that contains the value. 327 | /// The default is "val". 328 | /// [Optional] The name of the jQuery Validate rule. If not provided, the value 329 | /// of adapterName will be used instead. 330 | /// 331 | return this.add(adapterName, [attribute || "val"], function (options) { 332 | setValidationValues(options, ruleName || adapterName, options.params[attribute]); 333 | }); 334 | }; 335 | 336 | $jQval.addMethod("__dummy__", function (value, element, params) { 337 | return true; 338 | }); 339 | 340 | $jQval.addMethod("regex", function (value, element, params) { 341 | var match; 342 | if (this.optional(element)) { 343 | return true; 344 | } 345 | 346 | match = new RegExp(params).exec(value); 347 | return (match && (match.index === 0) && (match[0].length === value.length)); 348 | }); 349 | 350 | $jQval.addMethod("nonalphamin", function (value, element, nonalphamin) { 351 | var match; 352 | if (nonalphamin) { 353 | match = value.match(/\W/g); 354 | match = match && match.length >= nonalphamin; 355 | } 356 | return match; 357 | }); 358 | 359 | if ($jQval.methods.extension) { 360 | adapters.addSingleVal("accept", "mimtype"); 361 | adapters.addSingleVal("extension", "extension"); 362 | } else { 363 | // for backward compatibility, when the 'extension' validation method does not exist, such as with versions 364 | // of JQuery Validation plugin prior to 1.10, we should use the 'accept' method for 365 | // validating the extension, and ignore mime-type validations as they are not supported. 366 | adapters.addSingleVal("extension", "extension", "accept"); 367 | } 368 | 369 | adapters.addSingleVal("regex", "pattern"); 370 | adapters.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"); 371 | adapters.addMinMax("length", "minlength", "maxlength", "rangelength").addMinMax("range", "min", "max", "range"); 372 | adapters.addMinMax("minlength", "minlength").addMinMax("maxlength", "minlength", "maxlength"); 373 | adapters.add("equalto", ["other"], function (options) { 374 | var prefix = getModelPrefix(options.element.name), 375 | other = options.params.other, 376 | fullOtherName = appendModelPrefix(other, prefix), 377 | element = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(fullOtherName) + "']")[0]; 378 | 379 | setValidationValues(options, "equalTo", element); 380 | }); 381 | adapters.add("required", function (options) { 382 | // jQuery Validate equates "required" with "mandatory" for checkbox elements 383 | if (options.element.tagName.toUpperCase() !== "INPUT" || options.element.type.toUpperCase() !== "CHECKBOX") { 384 | setValidationValues(options, "required", true); 385 | } 386 | }); 387 | adapters.add("remote", ["url", "type", "additionalfields"], function (options) { 388 | var value = { 389 | url: options.params.url, 390 | type: options.params.type || "GET", 391 | data: {} 392 | }, 393 | prefix = getModelPrefix(options.element.name); 394 | 395 | $.each(splitAndTrim(options.params.additionalfields || options.element.name), function (i, fieldName) { 396 | var paramName = appendModelPrefix(fieldName, prefix); 397 | value.data[paramName] = function () { 398 | var field = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(paramName) + "']"); 399 | // For checkboxes and radio buttons, only pick up values from checked fields. 400 | if (field.is(":checkbox")) { 401 | return field.filter(":checked").val() || field.filter(":hidden").val() || ''; 402 | } 403 | else if (field.is(":radio")) { 404 | return field.filter(":checked").val() || ''; 405 | } 406 | return field.val(); 407 | }; 408 | }); 409 | 410 | setValidationValues(options, "remote", value); 411 | }); 412 | adapters.add("password", ["min", "nonalphamin", "regex"], function (options) { 413 | if (options.params.min) { 414 | setValidationValues(options, "minlength", options.params.min); 415 | } 416 | if (options.params.nonalphamin) { 417 | setValidationValues(options, "nonalphamin", options.params.nonalphamin); 418 | } 419 | if (options.params.regex) { 420 | setValidationValues(options, "regex", options.params.regex); 421 | } 422 | }); 423 | adapters.add("fileextensions", ["extensions"], function (options) { 424 | setValidationValues(options, "extension", options.params.extensions); 425 | }); 426 | 427 | $(function () { 428 | $jQval.unobtrusive.parse(document); 429 | }); 430 | 431 | return $jQval.unobtrusive; 432 | })); 433 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Scripts/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | // Unobtrusive validation support library for jQuery and jQuery Validate 2 | // Copyright (c) .NET Foundation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 4 | // @version v3.2.11 5 | !function(a){"function"==typeof define&&define.amd?define("jquery.validate.unobtrusive",["jquery-validation"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery-validation")):jQuery.validator.unobtrusive=a(jQuery)}(function(a){function e(a,e,n){a.rules[e]=n,a.message&&(a.messages[e]=a.message)}function n(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function t(a){return a.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function r(a){return a.substr(0,a.lastIndexOf(".")+1)}function i(a,e){return 0===a.indexOf("*.")&&(a=a.replace("*.",e)),a}function o(e,n){var r=a(this).find("[data-valmsg-for='"+t(n[0].name)+"']"),i=r.attr("data-valmsg-replace"),o=i?a.parseJSON(i)!==!1:null;r.removeClass("field-validation-valid").addClass("field-validation-error"),e.data("unobtrusiveContainer",r),o?(r.empty(),e.removeClass("input-validation-error").appendTo(r)):e.hide()}function d(e,n){var t=a(this).find("[data-valmsg-summary=true]"),r=t.find("ul");r&&r.length&&n.errorList.length&&(r.empty(),t.addClass("validation-summary-errors").removeClass("validation-summary-valid"),a.each(n.errorList,function(){a("
  • ").html(this.message).appendTo(r)}))}function s(e){var n=e.data("unobtrusiveContainer");if(n){var t=n.attr("data-valmsg-replace"),r=t?a.parseJSON(t):null;n.addClass("field-validation-valid").removeClass("field-validation-error"),e.removeData("unobtrusiveContainer"),r&&n.empty()}}function l(e){var n=a(this),t="__jquery_unobtrusive_validation_form_reset";if(!n.data(t)){n.data(t,!0);try{n.data("validator").resetForm()}finally{n.removeData(t)}n.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors"),n.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}}function u(e){var n=a(e),t=n.data(v),r=a.proxy(l,e),i=f.unobtrusive.options||{},u=function(n,t){var r=i[n];r&&a.isFunction(r)&&r.apply(e,t)};return t||(t={options:{errorClass:i.errorClass||"input-validation-error",errorElement:i.errorElement||"span",errorPlacement:function(){o.apply(e,arguments),u("errorPlacement",arguments)},invalidHandler:function(){d.apply(e,arguments),u("invalidHandler",arguments)},messages:{},rules:{},success:function(){s.apply(e,arguments),u("success",arguments)}},attachValidation:function(){n.off("reset."+v,r).on("reset."+v,r).validate(this.options)},validate:function(){return n.validate(),n.valid()}},n.data(v,t)),t}var m,f=a.validator,v="unobtrusiveValidation";return f.unobtrusive={adapters:[],parseElement:function(e,n){var t,r,i,o=a(e),d=o.parents("form")[0];d&&(t=u(d),t.options.rules[e.name]=r={},t.options.messages[e.name]=i={},a.each(this.adapters,function(){var n="data-val-"+this.name,t=o.attr(n),s={};void 0!==t&&(n+="-",a.each(this.params,function(){s[this]=o.attr(n+this)}),this.adapt({element:e,form:d,message:t,params:s,rules:r,messages:i}))}),a.extend(r,{__dummy__:!0}),n||t.attachValidation())},parse:function(e){var n=a(e),t=n.parents().addBack().filter("form").add(n.find("form")).has("[data-val=true]");n.find("[data-val=true]").each(function(){f.unobtrusive.parseElement(this,!0)}),t.each(function(){var a=u(this);a&&a.attachValidation()})}},m=f.unobtrusive.adapters,m.add=function(a,e,n){return n||(n=e,e=[]),this.push({name:a,params:e,adapt:n}),this},m.addBool=function(a,n){return this.add(a,function(t){e(t,n||a,!0)})},m.addMinMax=function(a,n,t,r,i,o){return this.add(a,[i||"min",o||"max"],function(a){var i=a.params.min,o=a.params.max;i&&o?e(a,r,[i,o]):i?e(a,n,i):o&&e(a,t,o)})},m.addSingleVal=function(a,n,t){return this.add(a,[n||"val"],function(r){e(r,t||a,r.params[n])})},f.addMethod("__dummy__",function(a,e,n){return!0}),f.addMethod("regex",function(a,e,n){var t;return!!this.optional(e)||(t=new RegExp(n).exec(a),t&&0===t.index&&t[0].length===a.length)}),f.addMethod("nonalphamin",function(a,e,n){var t;return n&&(t=a.match(/\W/g),t=t&&t.length>=n),t}),f.methods.extension?(m.addSingleVal("accept","mimtype"),m.addSingleVal("extension","extension")):m.addSingleVal("extension","extension","accept"),m.addSingleVal("regex","pattern"),m.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"),m.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range"),m.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength"),m.add("equalto",["other"],function(n){var o=r(n.element.name),d=n.params.other,s=i(d,o),l=a(n.form).find(":input").filter("[name='"+t(s)+"']")[0];e(n,"equalTo",l)}),m.add("required",function(a){"INPUT"===a.element.tagName.toUpperCase()&&"CHECKBOX"===a.element.type.toUpperCase()||e(a,"required",!0)}),m.add("remote",["url","type","additionalfields"],function(o){var d={url:o.params.url,type:o.params.type||"GET",data:{}},s=r(o.element.name);a.each(n(o.params.additionalfields||o.element.name),function(e,n){var r=i(n,s);d.data[r]=function(){var e=a(o.form).find(":input").filter("[name='"+t(r)+"']");return e.is(":checkbox")?e.filter(":checked").val()||e.filter(":hidden").val()||"":e.is(":radio")?e.filter(":checked").val()||"":e.val()}}),e(o,"remote",d)}),m.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&e(a,"minlength",a.params.min),a.params.nonalphamin&&e(a,"nonalphamin",a.params.nonalphamin),a.params.regex&&e(a,"regex",a.params.regex)}),m.add("fileextensions",["extensions"],function(a){e(a,"extension",a.params.extensions)}),a(function(){f.unobtrusive.parse(document)}),f.unobtrusive}); -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "About"; 3 | } 4 |

    @ViewBag.Title.

    5 |

    @ViewBag.Message

    6 | 7 |

    Use this area to provide additional information.

    8 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Contact"; 3 | } 4 |

    @ViewBag.Title.

    5 |

    @ViewBag.Message

    6 | 7 |
    8 | One Microsoft Way
    9 | Redmond, WA 98052-6399
    10 | P: 11 | 425.555.0100 12 |
    13 | 14 |
    15 | Support: Support@example.com
    16 | Marketing: Marketing@example.com 17 |
    -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Home Page"; 3 | } 4 | 5 |
    6 |

    ASP.NET

    7 |

    ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.

    8 |

    Learn more »

    9 |
    10 | 11 |
    12 |
    13 |

    Getting started

    14 |

    15 | ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that 16 | enables a clean separation of concerns and gives you full control over markup 17 | for enjoyable, agile development. 18 |

    19 |

    Learn more »

    20 |
    21 |
    22 |

    Get more libraries

    23 |

    NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.

    24 |

    Learn more »

    25 |
    26 |
    27 |

    Web Hosting

    28 |

    You can easily find a web hosting company that offers the right mix of features and price for your applications.

    29 |

    Learn more »

    30 |
    31 |
    -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Error 6 | 7 | 8 |
    9 |

    Error.

    10 |

    An error occurred while processing your request.

    11 |
    12 | 13 | 14 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewBag.Title - My ASP.NET Application 7 | @Styles.Render("~/Content/css") 8 | @Scripts.Render("~/bundles/modernizr") 9 | 10 | 11 | 30 |
    31 | @RenderBody() 32 |
    33 |
    34 |

    © @DateTime.Now.Year - My ASP.NET Application

    35 |
    36 |
    37 | 38 | @Scripts.Render("~/bundles/jquery") 39 | @Scripts.Render("~/bundles/bootstrap") 40 | @RenderSection("scripts", required: false) 41 | 42 | 43 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
    7 |
    8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 54 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/8. Deadlock/favicon.ico -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/8. Deadlock/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/8. Deadlock/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/8. Deadlock/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ivaylokenov/TestGit/939892268e5598fb1601f9f7b2992fddbbd7b60f/AsyncAwait/8. Deadlock/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /AsyncAwait/8. Deadlock/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /AsyncAwait/9. Cancellation/09. Cancellation.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | Cancellation 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /AsyncAwait/9. Cancellation/Program.cs: -------------------------------------------------------------------------------- 1 | namespace Cancellation 2 | { 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | public class Program 8 | { 9 | public static async Task Main() 10 | { 11 | // var cancellation = new CancellationTokenSource(2000); 12 | var cancellation = new CancellationTokenSource(); 13 | 14 | var printTask = Task.Run(async () => 15 | { 16 | while (true) 17 | { 18 | if (cancellation.IsCancellationRequested) 19 | { 20 | Console.WriteLine("Enough!"); 21 | 22 | // cancellation.Token.ThrowIfCancellationRequested(); 23 | 24 | break; 25 | } 26 | 27 | Console.WriteLine(DateTime.Now); 28 | 29 | await Task.Delay(1000); 30 | } 31 | }, cancellation.Token); 32 | 33 | var readTask = Task.Run(() => 34 | { 35 | while (true) 36 | { 37 | var input = Console.ReadLine(); 38 | 39 | if (input == "end") 40 | { 41 | cancellation.Cancel(); 42 | break; 43 | } 44 | } 45 | }); 46 | 47 | await Task.WhenAll(printTask, readTask); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /AsyncAwait/AsynAwaitPlayground.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29709.97 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "01. FromSyncToAsync", "1. FromSyncToAsync\01. FromSyncToAsync.csproj", "{61C57D70-A98A-4D38-A1B9-D6DE06BACCF7}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "02. BurgerPreparation", "2. BurgerPreparation\02. BurgerPreparation.csproj", "{E8227B19-151E-4589-B804-3A27DF2CB94F}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "03. MultithreadingAndAsynchronous", "3. MultithreadingAndAsynchronous\03. MultithreadingAndAsynchronous.csproj", "{C8B983D6-9D18-4BA1-BB3A-47831F8B3712}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "04. TaskMethods", "4. TaskMethods\04. TaskMethods.csproj", "{EAA4E431-B559-47B9-815F-8769E2C14272}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "05. AsyncAwait", "5. AsyncAwait\05. AsyncAwait.csproj", "{AE58B041-7E2C-44CF-B39C-3DD63CF19DC8}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "06. PerformanceExample", "6. PerformanceExample\06. PerformanceExample.csproj", "{1F96DC07-AAF6-4D3A-A565-1BAAE7F0160C}" 17 | EndProject 18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "07. Gotchas", "7. Gotchas\07. Gotchas.csproj", "{F3A5A858-1D3D-4350-ABD9-D09509A652DA}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "08. Deadlock", "8. Deadlock\08. Deadlock.csproj", "{040B2F7B-D047-4804-9AA0-61CEB81D9C4A}" 21 | EndProject 22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "09. Cancellation", "9. Cancellation\09. Cancellation.csproj", "{55CBCE20-EDBE-4F1D-B648-8FDE4DADB851}" 23 | EndProject 24 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "10. TasksBehindTheScenes", "10. TasksBehindTheScenes\10. TasksBehindTheScenes.csproj", "{5D2AD08B-A54D-4A78-B538-1E20FFBF45B8}" 25 | EndProject 26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "11. CustomAwait", "11. CustomAwait\11. CustomAwait.csproj", "{1F874A69-8F44-418D-B55A-A99291CEA031}" 27 | EndProject 28 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "12. ChildTasks", "12. ChildTasks\12. ChildTasks.csproj", "{EE6FE74E-0BFA-4913-80B8-D5EBCDA3D9A5}" 29 | EndProject 30 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "13. StateMachine", "13. StateMachine\13. StateMachine.csproj", "{F022C18D-D911-4D44-A05D-1DC6DD2C0CA9}" 31 | EndProject 32 | Global 33 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 34 | Debug|Any CPU = Debug|Any CPU 35 | Release|Any CPU = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 38 | {61C57D70-A98A-4D38-A1B9-D6DE06BACCF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {61C57D70-A98A-4D38-A1B9-D6DE06BACCF7}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {61C57D70-A98A-4D38-A1B9-D6DE06BACCF7}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {61C57D70-A98A-4D38-A1B9-D6DE06BACCF7}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {E8227B19-151E-4589-B804-3A27DF2CB94F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {E8227B19-151E-4589-B804-3A27DF2CB94F}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {E8227B19-151E-4589-B804-3A27DF2CB94F}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {E8227B19-151E-4589-B804-3A27DF2CB94F}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {C8B983D6-9D18-4BA1-BB3A-47831F8B3712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {C8B983D6-9D18-4BA1-BB3A-47831F8B3712}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {C8B983D6-9D18-4BA1-BB3A-47831F8B3712}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {C8B983D6-9D18-4BA1-BB3A-47831F8B3712}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {EAA4E431-B559-47B9-815F-8769E2C14272}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {EAA4E431-B559-47B9-815F-8769E2C14272}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {EAA4E431-B559-47B9-815F-8769E2C14272}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {EAA4E431-B559-47B9-815F-8769E2C14272}.Release|Any CPU.Build.0 = Release|Any CPU 54 | {AE58B041-7E2C-44CF-B39C-3DD63CF19DC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 55 | {AE58B041-7E2C-44CF-B39C-3DD63CF19DC8}.Debug|Any CPU.Build.0 = Debug|Any CPU 56 | {AE58B041-7E2C-44CF-B39C-3DD63CF19DC8}.Release|Any CPU.ActiveCfg = Release|Any CPU 57 | {AE58B041-7E2C-44CF-B39C-3DD63CF19DC8}.Release|Any CPU.Build.0 = Release|Any CPU 58 | {1F96DC07-AAF6-4D3A-A565-1BAAE7F0160C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 59 | {1F96DC07-AAF6-4D3A-A565-1BAAE7F0160C}.Debug|Any CPU.Build.0 = Debug|Any CPU 60 | {1F96DC07-AAF6-4D3A-A565-1BAAE7F0160C}.Release|Any CPU.ActiveCfg = Release|Any CPU 61 | {1F96DC07-AAF6-4D3A-A565-1BAAE7F0160C}.Release|Any CPU.Build.0 = Release|Any CPU 62 | {F3A5A858-1D3D-4350-ABD9-D09509A652DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 63 | {F3A5A858-1D3D-4350-ABD9-D09509A652DA}.Debug|Any CPU.Build.0 = Debug|Any CPU 64 | {F3A5A858-1D3D-4350-ABD9-D09509A652DA}.Release|Any CPU.ActiveCfg = Release|Any CPU 65 | {F3A5A858-1D3D-4350-ABD9-D09509A652DA}.Release|Any CPU.Build.0 = Release|Any CPU 66 | {040B2F7B-D047-4804-9AA0-61CEB81D9C4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 67 | {040B2F7B-D047-4804-9AA0-61CEB81D9C4A}.Debug|Any CPU.Build.0 = Debug|Any CPU 68 | {040B2F7B-D047-4804-9AA0-61CEB81D9C4A}.Release|Any CPU.ActiveCfg = Release|Any CPU 69 | {040B2F7B-D047-4804-9AA0-61CEB81D9C4A}.Release|Any CPU.Build.0 = Release|Any CPU 70 | {55CBCE20-EDBE-4F1D-B648-8FDE4DADB851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 71 | {55CBCE20-EDBE-4F1D-B648-8FDE4DADB851}.Debug|Any CPU.Build.0 = Debug|Any CPU 72 | {55CBCE20-EDBE-4F1D-B648-8FDE4DADB851}.Release|Any CPU.ActiveCfg = Release|Any CPU 73 | {55CBCE20-EDBE-4F1D-B648-8FDE4DADB851}.Release|Any CPU.Build.0 = Release|Any CPU 74 | {5D2AD08B-A54D-4A78-B538-1E20FFBF45B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 75 | {5D2AD08B-A54D-4A78-B538-1E20FFBF45B8}.Debug|Any CPU.Build.0 = Debug|Any CPU 76 | {5D2AD08B-A54D-4A78-B538-1E20FFBF45B8}.Release|Any CPU.ActiveCfg = Release|Any CPU 77 | {5D2AD08B-A54D-4A78-B538-1E20FFBF45B8}.Release|Any CPU.Build.0 = Release|Any CPU 78 | {1F874A69-8F44-418D-B55A-A99291CEA031}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 79 | {1F874A69-8F44-418D-B55A-A99291CEA031}.Debug|Any CPU.Build.0 = Debug|Any CPU 80 | {1F874A69-8F44-418D-B55A-A99291CEA031}.Release|Any CPU.ActiveCfg = Release|Any CPU 81 | {1F874A69-8F44-418D-B55A-A99291CEA031}.Release|Any CPU.Build.0 = Release|Any CPU 82 | {EE6FE74E-0BFA-4913-80B8-D5EBCDA3D9A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 83 | {EE6FE74E-0BFA-4913-80B8-D5EBCDA3D9A5}.Debug|Any CPU.Build.0 = Debug|Any CPU 84 | {EE6FE74E-0BFA-4913-80B8-D5EBCDA3D9A5}.Release|Any CPU.ActiveCfg = Release|Any CPU 85 | {EE6FE74E-0BFA-4913-80B8-D5EBCDA3D9A5}.Release|Any CPU.Build.0 = Release|Any CPU 86 | {F022C18D-D911-4D44-A05D-1DC6DD2C0CA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 87 | {F022C18D-D911-4D44-A05D-1DC6DD2C0CA9}.Debug|Any CPU.Build.0 = Debug|Any CPU 88 | {F022C18D-D911-4D44-A05D-1DC6DD2C0CA9}.Release|Any CPU.ActiveCfg = Release|Any CPU 89 | {F022C18D-D911-4D44-A05D-1DC6DD2C0CA9}.Release|Any CPU.Build.0 = Release|Any CPU 90 | EndGlobalSection 91 | GlobalSection(SolutionProperties) = preSolution 92 | HideSolutionNode = FALSE 93 | EndGlobalSection 94 | GlobalSection(ExtensibilityGlobals) = postSolution 95 | SolutionGuid = {EFE323CC-702B-4664-9D96-E19DF03C2E78} 96 | EndGlobalSection 97 | EndGlobal 98 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Ivaylo Kenov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MyConsoleApp/MyConsoleApp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31702.278 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyConsoleApp", "MyConsoleApp\MyConsoleApp.csproj", "{D192715A-D96D-43B4-B865-5C01B8A53A98}" 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 | {D192715A-D96D-43B4-B865-5C01B8A53A98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {D192715A-D96D-43B4-B865-5C01B8A53A98}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {D192715A-D96D-43B4-B865-5C01B8A53A98}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {D192715A-D96D-43B4-B865-5C01B8A53A98}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {7BC16E00-991E-4985-BB46-A67333CEB1E1} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /MyConsoleApp/MyConsoleApp/Cat.cs: -------------------------------------------------------------------------------- 1 | namespace MyConsoleApp 2 | { 3 | public class Cat 4 | { 5 | public string Name { get; set; } 6 | 7 | public int Age { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /MyConsoleApp/MyConsoleApp/MyConsoleApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MyConsoleApp/MyConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 | namespace MyConsoleApp 2 | { 3 | using System; 4 | 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Test Git 2 | Using this repository for a GitHub lecture at SoftUni. 3 | 4 | We covered the basics. 5 | -------------------------------------------------------------------------------- /Test.txt: -------------------------------------------------------------------------------- 1 | Adding additional data. 2 | 3 | Even more test data. --------------------------------------------------------------------------------