├── Chapter11 ├── Recipe1 │ ├── Assets │ │ ├── StoreLogo.png │ │ ├── LockScreenLogo.scale-200.png │ │ ├── SplashScreen.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Wide310x150Logo.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ └── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── Recipe1_TemporaryKey.pfx │ ├── ApplicationInsights.config │ ├── App.xaml │ ├── MainPage.xaml │ ├── project.json │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Default.rd.xml │ └── Package.appxmanifest ├── Recipe3 │ ├── Assets │ │ ├── StoreLogo.png │ │ ├── LockScreenLogo.scale-200.png │ │ ├── SplashScreen.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Wide310x150Logo.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ └── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── Recipe3_TemporaryKey.pfx │ ├── ApplicationInsights.config │ ├── App.xaml │ ├── project.json │ ├── MainPage.xaml │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Default.rd.xml │ └── Package.appxmanifest ├── Recipe4 │ ├── dotnetcore_installation.txt │ └── Program.cs ├── Recipe5 │ ├── dotnetcore_installation.txt │ └── Program.cs └── Recipe2 │ ├── Properties │ └── AssemblyInfo.cs │ └── Program.cs ├── Chapter10 ├── Recipe4 │ ├── packages.config │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe3 │ ├── packages.config │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe1 │ └── Properties │ │ └── AssemblyInfo.cs └── Recipe2 │ └── Properties │ └── AssemblyInfo.cs ├── Chapter5 ├── Recipe9 │ ├── packages.config │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe2 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe4 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe1 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe3 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe5 │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe6 │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe7 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs └── Recipe8 │ ├── Properties │ └── AssemblyInfo.cs │ └── Program.cs ├── Chapter4 ├── Recipe9 │ ├── App.xaml.cs │ ├── Properties │ │ ├── Settings.settings │ │ └── Settings.Designer.cs │ ├── App.xaml │ └── MainWindow.xaml ├── Recipe1 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe5 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe2 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe3 │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe4 │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe6 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe7 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs └── Recipe8 │ ├── Properties │ └── AssemblyInfo.cs │ └── Program.cs ├── .gitattributes ├── Chapter8 ├── Recipe1 │ ├── packages.config │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe2 │ ├── packages.config │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe3 │ ├── packages.config │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe4 │ ├── packages.config │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe5 │ ├── packages.config │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs └── Recipe6 │ ├── packages.config │ └── Properties │ └── AssemblyInfo.cs ├── Chapter1 ├── Recipe1 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe3 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe4 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe2 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe11 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe7 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe5 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe10 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe6 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe8 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs └── Recipe9 │ ├── Properties │ └── AssemblyInfo.cs │ └── Program.cs ├── Chapter2 ├── Recipe2 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe6 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe3 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe7 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe9 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe4 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe5 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe1 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs └── Recipe8 │ ├── Properties │ └── AssemblyInfo.cs │ └── Program.cs ├── .gitignore ├── README.md ├── Chapter3 ├── Recipe6 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe2 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe1 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe3 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe4 │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe5 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs └── Recipe7 │ ├── Properties │ └── AssemblyInfo.cs │ └── Program.cs ├── LICENSE ├── Chapter7 ├── Recipe4 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe1 │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe2 │ └── Properties │ │ └── AssemblyInfo.cs ├── Recipe3 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe5 │ └── Properties │ │ └── AssemblyInfo.cs └── Recipe6 │ └── Properties │ └── AssemblyInfo.cs ├── Chapter6 ├── Recipe1 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe2 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe3 │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Recipe4 │ └── Properties │ │ └── AssemblyInfo.cs └── Recipe5 │ ├── Properties │ └── AssemblyInfo.cs │ └── Program.cs └── Chapter9 ├── Recipe1 └── Properties │ └── AssemblyInfo.cs ├── Recipe2 └── Properties │ └── AssemblyInfo.cs ├── Recipe3 └── Properties │ └── AssemblyInfo.cs └── Recipe4 └── Properties └── AssemblyInfo.cs /Chapter11/Recipe1/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe1/Assets/StoreLogo.png -------------------------------------------------------------------------------- /Chapter11/Recipe3/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe3/Assets/StoreLogo.png -------------------------------------------------------------------------------- /Chapter10/Recipe4/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter5/Recipe9/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter11/Recipe1/Recipe1_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe1/Recipe1_TemporaryKey.pfx -------------------------------------------------------------------------------- /Chapter11/Recipe3/Recipe3_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe3/Recipe3_TemporaryKey.pfx -------------------------------------------------------------------------------- /Chapter10/Recipe3/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter11/Recipe1/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe1/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /Chapter11/Recipe1/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe1/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /Chapter11/Recipe3/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe3/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /Chapter11/Recipe3/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe3/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /Chapter11/Recipe1/ApplicationInsights.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter11/Recipe1/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe1/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /Chapter11/Recipe1/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe1/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /Chapter11/Recipe3/ApplicationInsights.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Chapter11/Recipe3/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe3/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /Chapter11/Recipe3/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe3/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /Chapter11/Recipe1/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe1/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /Chapter11/Recipe3/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe3/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /Chapter4/Recipe9/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Chapter4.Recipe9 4 | { 5 | /// 6 | /// Interaction logic for App.xaml 7 | /// 8 | public partial class App : Application 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /Chapter11/Recipe1/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe1/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /Chapter11/Recipe3/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/MultithreadingwithCSharpCookbookSecondEdition_Code/HEAD/Chapter11/Recipe3/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /Chapter4/Recipe9/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Chapter11/Recipe1/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Chapter11/Recipe3/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Chapter11/Recipe4/dotnetcore_installation.txt: -------------------------------------------------------------------------------- 1 | #please do it on your own risk! 2 | sudo sysctl -w kern.maxfiles=20480 3 | 4 | sudo sysctl -w kern.maxfilesperproc=18000 5 | 6 | sudo ulimit -S -n 2048 7 | 8 | mkdir HelloWorld 9 | 10 | cd HelloWorld 11 | 12 | dotnet new 13 | 14 | dotnet restore 15 | 16 | dotnet run 17 | -------------------------------------------------------------------------------- /Chapter4/Recipe9/App.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Chapter11/Recipe5/dotnetcore_installation.txt: -------------------------------------------------------------------------------- 1 | sudo sh -c 'echo "deb [arch=amd64] http://apt-mo.trafficmanager.net/repos/dotnet/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' 2 | 3 | sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 4 | 5 | sudo apt-get update 6 | 7 | mkdir HelloWorld 8 | 9 | cd HelloWorld 10 | 11 | dotnet new 12 | 13 | dotnet restore 14 | 15 | dotnet run -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /Chapter8/Recipe1/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter8/Recipe2/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter8/Recipe3/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter8/Recipe4/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter8/Recipe5/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter8/Recipe6/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Chapter1/Recipe1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using static System.Console; 4 | 5 | namespace Chapter1.Recipe1 6 | { 7 | class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | Thread t = new Thread(PrintNumbers); 12 | t.Start(); 13 | PrintNumbers(); 14 | } 15 | 16 | static void PrintNumbers() 17 | { 18 | WriteLine("Starting..."); 19 | for (int i = 1; i < 10; i++) 20 | { 21 | WriteLine(i); 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter11/Recipe1/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Chapter11/Recipe1/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.ApplicationInsights": "1.0.0", 4 | "Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0", 5 | "Microsoft.ApplicationInsights.WindowsApps": "1.0.0", 6 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" 7 | }, 8 | "frameworks": { 9 | "uap10.0": {} 10 | }, 11 | "runtimes": { 12 | "win10-arm": {}, 13 | "win10-arm-aot": {}, 14 | "win10-x86": {}, 15 | "win10-x86-aot": {}, 16 | "win10-x64": {}, 17 | "win10-x64-aot": {} 18 | } 19 | } -------------------------------------------------------------------------------- /Chapter11/Recipe3/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.ApplicationInsights": "1.0.0", 4 | "Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0", 5 | "Microsoft.ApplicationInsights.WindowsApps": "1.0.0", 6 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" 7 | }, 8 | "frameworks": { 9 | "uap10.0": {} 10 | }, 11 | "runtimes": { 12 | "win10-arm": {}, 13 | "win10-arm-aot": {}, 14 | "win10-x86": {}, 15 | "win10-x86-aot": {}, 16 | "win10-x64": {}, 17 | "win10-x64-aot": {} 18 | } 19 | } -------------------------------------------------------------------------------- /Chapter2/Recipe2/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using static System.Console; 4 | 5 | namespace Chapter2.Recipe2 6 | { 7 | class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | const string MutexName = "CSharpThreadingCookbook"; 12 | 13 | using (var m = new Mutex(false, MutexName)) 14 | { 15 | if (!m.WaitOne(TimeSpan.FromSeconds(5), false)) 16 | { 17 | WriteLine("Second instance is running!"); 18 | } 19 | else 20 | { 21 | WriteLine("Running!"); 22 | ReadLine(); 23 | m.ReleaseMutex(); 24 | } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Chapter1/Recipe3/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using static System.Console; 4 | using static System.Threading.Thread; 5 | 6 | namespace Chapter1.Recipe3 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | WriteLine("Starting program..."); 13 | Thread t = new Thread(PrintNumbersWithDelay); 14 | t.Start(); 15 | t.Join(); 16 | WriteLine("Thread completed"); 17 | } 18 | 19 | static void PrintNumbersWithDelay() 20 | { 21 | WriteLine("Starting..."); 22 | for (int i = 1; i < 10; i++) 23 | { 24 | Sleep(TimeSpan.FromSeconds(2)); 25 | WriteLine(i); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Chapter1/Recipe4/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using static System.Console; 4 | using static System.Threading.Thread; 5 | 6 | namespace Chapter1.Recipe4 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | WriteLine("Starting program..."); 13 | Thread t = new Thread(PrintNumbersWithDelay); 14 | t.Start(); 15 | Sleep(TimeSpan.FromSeconds(6)); 16 | t.Abort(); 17 | WriteLine("A thread has been aborted"); 18 | } 19 | 20 | static void PrintNumbersWithDelay() 21 | { 22 | WriteLine("Starting..."); 23 | for (int i = 1; i < 10; i++) 24 | { 25 | Sleep(TimeSpan.FromSeconds(2)); 26 | WriteLine(i); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Chapter11/Recipe3/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Chapter1/Recipe2/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using static System.Console; 4 | using static System.Threading.Thread; 5 | 6 | namespace Chapter1.Recipe2 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | Thread t = new Thread(PrintNumbersWithDelay); 13 | t.Start(); 14 | PrintNumbers(); 15 | } 16 | 17 | static void PrintNumbers() 18 | { 19 | WriteLine("Starting..."); 20 | for (int i = 1; i < 10; i++) 21 | { 22 | WriteLine(i); 23 | } 24 | } 25 | 26 | static void PrintNumbersWithDelay() 27 | { 28 | WriteLine("Starting..."); 29 | for (int i = 1; i < 10; i++) 30 | { 31 | Sleep(TimeSpan.FromSeconds(2)); 32 | WriteLine(i); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Chapter5/Recipe2/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using static System.Console; 4 | using static System.Threading.Thread; 5 | 6 | namespace Chapter5.Recipe2 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | Task t = AsynchronousProcessing(); 13 | t.Wait(); 14 | } 15 | 16 | static async Task AsynchronousProcessing() 17 | { 18 | Func> asyncLambda = async name => { 19 | await Task.Delay(TimeSpan.FromSeconds(2)); 20 | return 21 | $"Task {name} is running on a thread id {CurrentThread.ManagedThreadId}." + 22 | $" Is thread pool thread: {CurrentThread.IsThreadPoolThread}"; 23 | }; 24 | 25 | string result = await asyncLambda("async lambda"); 26 | 27 | WriteLine(result); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /Chapter4/Recipe9/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 |