{"id":912,"date":"2023-03-12T09:55:46","date_gmt":"2023-03-12T02:55:46","guid":{"rendered":"https:\/\/csharptutorial.net\/?page_id=912"},"modified":"2023-03-12T09:57:02","modified_gmt":"2023-03-12T02:57:02","slug":"csharp-countdownevent","status":"publish","type":"page","link":"https:\/\/www.csharptutorial.net\/csharp-concurrency\/csharp-countdownevent\/","title":{"rendered":"C# CountdownEvent"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the C# <code>CountdownEvent<\/code> class to wait for a specified number of events before continuing execution.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to the C# CountdownEvent class<\/h2>\n\n\n\n<p>The <code><code>CountdownEvent<\/code><\/code> unblocks a waiting <a href=\"https:\/\/csharptutorial.net\/csharp-concurrency\/csharp-thread\/\">thread<\/a> until it receives the number of events. To use the <code><code>CountdownEvent<\/code><\/code> class, you follow these steps:<\/p>\n\n\n\n<p>First, create a new instance of the <code>CountdownEvent<\/code> class, passing an initial count value:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">var<\/span> countdownEvent = <span class=\"hljs-keyword\">new<\/span> CountdownEvent(<span class=\"hljs-number\">3<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, create one or more threads that will signal an event. Each thread needs to call the <code>Signal()<\/code> method of the <code>CountdownEvent<\/code> object to signal an event:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-comment\">\/\/ inside a thread<\/span>\ncountdownEvent.Signal();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>Signal()<\/code> method decrements the initial count by one.<\/p>\n\n\n\n<p>Third, call the <code><code>Wait()<\/code><\/code> method of the <code>CountdownEvent<\/code> object on the waiting threads. The <code><code>Wait()<\/code><\/code> method will block these threads until the count reaches zero:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-comment\">\/\/ on the waiting thread<\/span>\ncountdownEvent.Wait();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If an exception occurs that causes the <code>Signal()<\/code> method not to be called, the <code>Wait()<\/code> method will block the waiting thread indefinitely. <\/p>\n\n\n\n<p>Therefore, you should always call the <code>Signal()<\/code> method even if an exception occurs. <\/p>\n\n\n\n<p>Also, you can set a timeout so that the <code>Wait()<\/code> method will unblock the waiting thread if a time interval has elapsed or the count of the <code>CountDownEvent<\/code> object has reached zero:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">countdownEvent.Wait(timeout);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, call the <code>Dispose()<\/code> method once you&#8217;re done using the <code>CountdownEvent<\/code> object to release any resources associated with it:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">countdownEvent.Dispose();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following example demonstrates how the <code>CountdownEvent<\/code> class works:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">using<\/span> <span class=\"hljs-keyword\">static<\/span> System.Console;\n\n<span class=\"hljs-keyword\">var<\/span> countdownEvent = <span class=\"hljs-keyword\">new<\/span> CountdownEvent(<span class=\"hljs-number\">3<\/span>);\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">DoWork<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">int<\/span> id<\/span>)<\/span>\n{\n    Thread.Sleep(<span class=\"hljs-number\">1000<\/span>);\n    WriteLine(<span class=\"hljs-string\">$\"Completed the task <span class=\"hljs-subst\">{id}<\/span> \"<\/span>);\n    countdownEvent.Signal();\n\n}\n\n<span class=\"hljs-comment\">\/\/ create three threads that executes the DoWork<\/span>\n<span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">int<\/span> i = <span class=\"hljs-number\">1<\/span>; i &lt;= <span class=\"hljs-number\">3<\/span>; i++)\n{\n    <span class=\"hljs-keyword\">var<\/span> id = i;\n    <span class=\"hljs-keyword\">var<\/span> thread = <span class=\"hljs-keyword\">new<\/span> Thread(() =&gt; DoWork(id));\n    thread.Start();\n}\n\n\n<span class=\"hljs-comment\">\/\/ block the main thread<\/span>\ncountdownEvent.Wait();\n\n<span class=\"hljs-comment\">\/\/ execute this once three event has been signaled<\/span>\nConsole.WriteLine(<span class=\"hljs-string\">\"All thread completed.\"<\/span>);\n\ncountdownEvent.Dispose();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">Completed the task <span class=\"hljs-number\">2<\/span>\nCompleted the task <span class=\"hljs-number\">1<\/span>\nCompleted the task <span class=\"hljs-number\">3<\/span>\nAll thread completed.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, create a new <code>CountdownEvent<\/code> object with the initial count 3:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">var<\/span> countdownEvent = <span class=\"hljs-keyword\">new<\/span> CountdownEvent(<span class=\"hljs-number\">3<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, define the <code>DoWork()<\/code> method that simulates a task taking one second to complete:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">DoWork<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">int<\/span> id<\/span>)<\/span>\n{\n    Thread.Sleep(<span class=\"hljs-number\">1000<\/span>);\n    WriteLine(<span class=\"hljs-string\">$\"Completed the task <span class=\"hljs-subst\">{id}<\/span> \"<\/span>);\n    countdownEvent.Signal();\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>DoWork()<\/code> calls the <code>Signal()<\/code> method of the <code>CountdownEvent<\/code> object to decrement the count once it completes. <\/p>\n\n\n\n<p>Third, create three threads that execute the <code>DoWork()<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">int<\/span> i = <span class=\"hljs-number\">1<\/span>; i &lt;= <span class=\"hljs-number\">3<\/span>; i++)\n{\n    <span class=\"hljs-keyword\">var<\/span> id = i;\n    <span class=\"hljs-keyword\">var<\/span> thread = <span class=\"hljs-keyword\">new<\/span> Thread(() =&gt; DoWork(id));\n    thread.Start();\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fourth, call the <code>Wait()<\/code> method on the main thread to block it until the <code>CountdownEvent<\/code> object receives three signals:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">countdownEvent.Wait();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Once the <code><code>CountdownEvent<\/code><\/code> reaches zero, the main thread is unblocked that executes the rest of the code, writing a message to the console and disposing of the <code><code>CountdownEvent<\/code><\/code> object:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-comment\">\/\/ execute this once three event has been signaled<\/span>\nConsole.WriteLine(<span class=\"hljs-string\">\"All thread completed.\"<\/span>);\n\ncountdownEvent.Dispose();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">C# CountdownEvent applications<\/h2>\n\n\n\n<p>In practice, you can use the <code>CountdownEvent<\/code> class in the following applications:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Parallel processing:  you can process a large dataset in multiple threads and use a <code>CountdownEvent<\/code> object to synchronize the completion of all threads before proceeding to the next step in the processing pipeline.<\/li>\n\n\n\n<li>File download: you can download multiple files in parallel and use a <code>CountdownEvent<\/code> object to wait until all the files have been downloaded before processing them.<\/li>\n\n\n\n<li>Waiting for external events: suppose your program needs to wait for multiple external events such as network messages or sensor readings before proceeding. In this case, you can use a <code>CountdownEvent<\/code> object to ensure all signals have been received before continuing.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">A practical example of C# CountdownEvent class<\/h2>\n\n\n\n<p>The following program downloads three text files concurrently from a remote server and counts the words of each. It uses the <code>CountdownEvent<\/code> object to wait for the downloads to complete before returning the total word count of three files:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">\n<span class=\"hljs-keyword\">var<\/span> urls = <span class=\"hljs-keyword\">new<\/span> List&lt;<span class=\"hljs-keyword\">string<\/span>&gt;()\n{\n    <span class=\"hljs-string\">\"https:\/\/www.ietf.org\/rfc\/rfc791.txt\"<\/span>,\n    <span class=\"hljs-string\">\"https:\/\/www.ietf.org\/rfc\/rfc792.txt\"<\/span>,\n    <span class=\"hljs-string\">\"https:\/\/www.ietf.org\/rfc\/rfc793.txt\"<\/span>\n};\n\n<span class=\"hljs-keyword\">var<\/span> countDownEvent = <span class=\"hljs-keyword\">new<\/span> CountdownEvent(urls.Count);\n<span class=\"hljs-keyword\">int<\/span> totalWordCount = <span class=\"hljs-number\">0<\/span>;\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">async<\/span> Task&lt;<span class=\"hljs-keyword\">int<\/span>&gt; <span class=\"hljs-title\">DownloadAndCountWords<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span> url<\/span>)<\/span>\n{\n    Console.WriteLine(<span class=\"hljs-string\">$\"Downloading the file <span class=\"hljs-subst\">{url}<\/span>...\"<\/span>);\n\n    <span class=\"hljs-keyword\">using<\/span> <span class=\"hljs-keyword\">var<\/span> client = <span class=\"hljs-keyword\">new<\/span> HttpClient();\n    <span class=\"hljs-keyword\">string<\/span> content = <span class=\"hljs-keyword\">await<\/span> client.GetStringAsync(url);\n\n    Console.WriteLine(<span class=\"hljs-string\">$\"File <span class=\"hljs-subst\">{url}<\/span> downloaded.\"<\/span>);\n\n    <span class=\"hljs-keyword\">int<\/span> wordCount = CountWords(content);\n    Console.WriteLine(<span class=\"hljs-string\">$\"Word count of <span class=\"hljs-subst\">{url}<\/span>: <span class=\"hljs-subst\">{wordCount}<\/span>\"<\/span>);\n\n    <span class=\"hljs-keyword\">return<\/span> wordCount;\n}\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">int<\/span> <span class=\"hljs-title\">CountWords<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span> text<\/span>)<\/span>\n{\n    <span class=\"hljs-keyword\">var<\/span> delimiters = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-keyword\">char<\/span>&#91;] { <span class=\"hljs-string\">' '<\/span>, <span class=\"hljs-string\">'\\r'<\/span>, <span class=\"hljs-string\">'\\n'<\/span> };\n    <span class=\"hljs-keyword\">return<\/span> text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries).Length;\n}\n\n\nurls.ForEach(url =&gt;\n{\n    Task.Run(<span class=\"hljs-keyword\">async<\/span> () =&gt;\n    {\n        <span class=\"hljs-keyword\">int<\/span> wordCount = <span class=\"hljs-keyword\">await<\/span> DownloadAndCountWords(url);\n        Interlocked.Add(<span class=\"hljs-keyword\">ref<\/span> totalWordCount, wordCount);\n        \n        <span class=\"hljs-comment\">\/\/ signal an event<\/span>\n        countDownEvent.Signal();\n    });\n\n});\n\ncountDownEvent.Wait(TimeSpan.FromSeconds(<span class=\"hljs-number\">3<\/span>));\ncountDownEvent.Dispose();\n\nConsole.WriteLine(<span class=\"hljs-string\">$\"Total word count: <span class=\"hljs-subst\">{totalWordCount}<\/span>\"<\/span>);\nConsole.WriteLine(<span class=\"hljs-string\">\"Press any key to exit.\"<\/span>);\nConsole.ReadKey();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">Downloading the file https:<span class=\"hljs-comment\">\/\/www.ietf.org\/rfc\/rfc791.txt...<\/span>\nDownloading the file https:<span class=\"hljs-comment\">\/\/www.ietf.org\/rfc\/rfc792.txt...<\/span>\nDownloading the file https:<span class=\"hljs-comment\">\/\/www.ietf.org\/rfc\/rfc793.txt...<\/span>\nFile https:<span class=\"hljs-comment\">\/\/www.ietf.org\/rfc\/rfc792.txt downloaded.<\/span>\nWord count of https:<span class=\"hljs-comment\">\/\/www.ietf.org\/rfc\/rfc792.txt: 3714<\/span>\nFile https:<span class=\"hljs-comment\">\/\/www.ietf.org\/rfc\/rfc791.txt downloaded.<\/span>\nWord count of https:<span class=\"hljs-comment\">\/\/www.ietf.org\/rfc\/rfc791.txt: 11243<\/span>\nFile https:<span class=\"hljs-comment\">\/\/www.ietf.org\/rfc\/rfc793.txt downloaded.<\/span>\nWord count of https:<span class=\"hljs-comment\">\/\/www.ietf.org\/rfc\/rfc793.txt: 21460<\/span>\nTotal word count: <span class=\"hljs-number\">36417<\/span>\nPress any key to exit.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use C# <code>CountdownEvent<\/code> to allow threads to wait until a specified number of events have been signaled.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"912\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-concurrency\/csharp-countdownevent\/\"\n\t\t\t\tdata-post-title=\"C# CountdownEvent\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"912\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-concurrency\/csharp-countdownevent\/\"\n\t\t\t\tdata-post-title=\"C# CountdownEvent\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn how to use the C# CountdownEvent class to wait for a specified number of events before continuing execution.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":760,"menu_order":17,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-912","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/912","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/comments?post=912"}],"version-history":[{"count":2,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/912\/revisions"}],"predecessor-version":[{"id":914,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/912\/revisions\/914"}],"up":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/760"}],"wp:attachment":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/media?parent=912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}