{"id":19078474,"url":"https://github.com/sikatikenmogne/tpl-csharp-workshop","last_synced_at":"2025-09-05T18:42:49.093Z","repository":{"id":238908091,"uuid":"797122176","full_name":"sikatikenmogne/TPL-csharp-workshop","owner":"sikatikenmogne","description":"This project is a hands-on workshop focused on exploring and understanding the concepts of parallel programming in C#. It provides practical examples of using delegates, events, and various parallel programming constructs such as Parallel.For, Parallel.ForEach, Parallel.Invoke, and Task.Factory in a console application. ","archived":false,"fork":false,"pushed_at":"2024-05-08T22:29:17.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-02T18:43:47.889Z","etag":null,"topics":["console-application","csharp","dotnet-framework","dotnet-framework-472","jetbrains-rider","microsoft","mutex","mutex-lock","parallel-processing","parallel-programming","task","task-parallel-library","threading","tpl","visual-studio"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sikatikenmogne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-07T08:33:03.000Z","updated_at":"2024-05-08T22:29:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"83557ad1-8ba3-47e6-8037-e496b003edad","html_url":"https://github.com/sikatikenmogne/TPL-csharp-workshop","commit_stats":null,"previous_names":["sikatikenmogne/tpl-csharp-workshop"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sikatikenmogne%2FTPL-csharp-workshop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sikatikenmogne%2FTPL-csharp-workshop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sikatikenmogne%2FTPL-csharp-workshop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sikatikenmogne%2FTPL-csharp-workshop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sikatikenmogne","download_url":"https://codeload.github.com/sikatikenmogne/TPL-csharp-workshop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240131729,"owners_count":19752725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console-application","csharp","dotnet-framework","dotnet-framework-472","jetbrains-rider","microsoft","mutex","mutex-lock","parallel-processing","parallel-programming","task","task-parallel-library","threading","tpl","visual-studio"],"created_at":"2024-11-09T02:09:40.492Z","updated_at":"2025-02-22T05:26:55.242Z","avatar_url":"https://github.com/sikatikenmogne.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# TPL-csharp-workshop\n\nThis workshop is a practical application of various techniques related to parallel programming in C#. The main objective is to provide hands-on experience with the concepts and tools necessary to solve problems related to parallel programming.\n\n## Workshop Objectives\n\nAfter completing this workshop, you will be able to:\n\n- Manipulate a `Parallel.For`\n- Manipulate a `Parallel.ForEach`\n- Manipulate a `Parallel.Invoke`\n- Manipulate Tasks\n- Manipulate an event\n- Manipulate a delegate multi-cast\n\nAll exercises are performed in console-type applications. This workshop is designed to enhance your technical skills in this module. However, consistent work and rigorous implementation are essential for successful completion.\n\n## Duration\n\nThis workshop is expected to take approximately 4 hours.\n\n## Exercises\n\n### Q1 — Code Observation\n\nObserve the provided code in the [`Program.cs`](https://github.com/sikatikenmogne/TPL-csharp-workshop/blob/main/Program.cs) file. This code demonstrates the use of delegates, events, and parallel programming constructs.\n\n---\n\n### Q2 — Code Philosophy\n\nUnderstand the philosophy of the provided code. What is it trying to achieve and how does it use the concepts of parallel programming to do so?\n\n#### Answer:\n- **[✍️ related \"essay\"](https://github.com/sikatikenmogne/TPL-csharp-workshop/blob/2-code-philosophy/README.md#q2--code-philosophy)**\n\n---\n\n### Q3 — Code Translation\n\nTranslate the provided code line by line. Understand what each line of code does and how it contributes to the overall functionality of the program.\n\n#### Answer:\n- **[✍️ related code](https://github.com/sikatikenmogne/TPL-csharp-workshop/blob/3-code-translation/Program.cs)**\n\n---\n\n### Q4 — Parallel.For\n\nWrite a simple program that demonstrates the use of `Parallel.For`. This construct is used to execute a `for` loop in parallel, which can significantly improve performance for CPU-bound tasks.\n\n#### Answer:\n- **[✍️ related code](https://github.com/sikatikenmogne/TPL-csharp-workshop/blob/4-parallel-for/Program.cs)**\n\n```text\nIn this code, Parallel.For is used to execute a for loop in parallel. The loop runs from 0 to 9,\nand for each iteration,it calculates the square of the current number and prints it. The order \nof the output may vary because the iterations are running in parallel.\n```\n\n---\n\n### Q5 — Parallel.ForEach\n\nWrite a simple program that demonstrates the use of `Parallel.ForEach`. This construct is used to execute a `foreach` loop in parallel, which can significantly improve performance when processing collections of data.\n\n#### Answer:\n- **[✍️ related code](https://github.com/sikatikenmogne/TPL-csharp-workshop/blob/5-parallel-foreach/Program.cs)**\n\n```text\nThe code you provided is a good example of using Parallel.ForEach to improve performance when\nprocessing large collections of data. It calculates prime numbers in a list using both a \nregular foreach loop and Parallel.ForEach, and compares the time taken for each method.\n```\n\n---\n\n### Q6 — Parallel.Invoke\n\nWrite a simple program that demonstrates the use of `Parallel.Invoke`. This construct is used to execute multiple methods in parallel.\n\n#### Answer:\n- **[✍️ related code](https://github.com/sikatikenmogne/TPL-csharp-workshop/blob/6-parallel-invoke/Program.cs)**\n\n```text\nIn this code, Parallel.Invoke is used to execute three methods in parallel: BasicAction, \na lambda expression, and an inline delegate. Each method prints a message to the console \nalong with the ID of the thread it's running on\n```\n\n---\n\n### Q7 — Task.Factory\n\nWrite a simple program that demonstrates the use of `Task.Factory`. This construct is used to start and manage tasks.\n\n#### Answer:\n- **[✍️ related code](https://github.com/sikatikenmogne/TPL-csharp-workshop/blob/7-parallel-factory/Program.cs)**\n\n```text\nThis code is a simple C# program that demonstrates the use of Task.Factory.StartNew.\nThis method is used to create and start a new Task in one operation.\n\nin this code, an array of Task objects is created. Then, a for loop is used to create\nand start a new Task for each element in the array. Each Task prints a message to the \nconsole indicating that it has started, sleeps for a period of time proportional \nto its index in the array (simulating work), and then prints a message indicating that it has completed. \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsikatikenmogne%2Ftpl-csharp-workshop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsikatikenmogne%2Ftpl-csharp-workshop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsikatikenmogne%2Ftpl-csharp-workshop/lists"}