{"id":901,"date":"2023-03-11T20:50:24","date_gmt":"2023-03-11T13:50:24","guid":{"rendered":"https:\/\/csharptutorial.net\/?page_id=901"},"modified":"2023-03-11T21:56:06","modified_gmt":"2023-03-11T14:56:06","slug":"csharp-manualreseteventslim","status":"publish","type":"page","link":"https:\/\/www.csharptutorial.net\/csharp-concurrency\/csharp-manualreseteventslim\/","title":{"rendered":"C# ManualResetEventSlim"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the C# <code>ManualResetEventSlim<\/code> to provide a way for threads to communicate with each other.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to the C# ManualResetEventSlim class<\/h2>\n\n\n\n<p>The <code>ManualResetEventSlim<\/code> class allows threads to wait for a signal from another thread before continuing execution. In other words, the <code>ManualResetEventSlim<\/code> class allows you to synchronize the execution of multiple threads. <\/p>\n\n\n\n<p>Like an <code><a href=\"https:\/\/csharptutorial.net\/csharp-concurrency\/csharp-autoresetevent\/\">AutoResetEvent<\/a><\/code> object, a <code>ManualResetEventSlim<\/code> object has two states:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Signaled<\/li>\n\n\n\n<li>Non-signaled<\/li>\n<\/ul>\n\n\n\n<p>The <code>ManualResetEventSlim<\/code> class is called &#8220;Manual&#8221; because once the event is signaled, it remains signaled until you manually reset it.<\/p>\n\n\n\n<p>Also, the <code>ManualResetEventSlim<\/code> class is called &#8220;Slim&#8221; because it is a lightweight implementation of the <code>ManualResetEvent<\/code> class. The <code>ManualResetEventSlim<\/code> is optimized for performance and uses less memory than the <code>ManualResetEvent<\/code> class.<\/p>\n\n\n\n<p>To use the <code>ManualResetEventSlim<\/code> class, you follow these steps:<\/p>\n\n\n\n<p>First, create a new <code>ManualResetEventSlim<\/code> object:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">var<\/span> resetEvent = <span class=\"hljs-keyword\">new<\/span> ManualResetEventSlim(<span class=\"hljs-literal\">false<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>false<\/code> argument, which we pass the constructor, sets the initial state of the event to non-signaled.<\/p>\n\n\n\n<p>Second, create one or more threads that wait for the event to be signaled:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">var<\/span> t = <span class=\"hljs-keyword\">new<\/span> Thread(<span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> {\n    <span class=\"hljs-comment\">\/\/ do some work<\/span>\n    <span class=\"hljs-comment\">\/\/ ...<\/span>\n    <span class=\"hljs-comment\">\/\/ wait for the event to be signaled<\/span>\n    resetEvent.Wait();\n\n    <span class=\"hljs-comment\">\/\/ continue the execution after the event is signaled<\/span>\n});<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>Wait()<\/code> method will block the waiting threads until the event is signaled.<\/p>\n\n\n\n<p>Third, start the thread:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">t<\/span><span class=\"hljs-selector-class\">.Start<\/span>();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fourth, signal the event by calling the <code>Set()<\/code> method on the <code>ManualResetEventSlim<\/code> object:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">resetEvent<\/span><span class=\"hljs-selector-class\">.Set<\/span>();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>Set()<\/code> method releases all the threads that waiting on the event to resume their executions until the next <code>Reset()<\/code> method is called on the <code>ManualResetEventSlim<\/code> object.<\/p>\n\n\n\n<p>Fifth, call the <code>Reset()<\/code> method of the <code>ManualResetEventSlim<\/code> object to reset the state to non-signaled, which blocks all the waiting threads:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">resetEvent<\/span><span class=\"hljs-selector-class\">.Reset<\/span>();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">C# ManualResetEventSlim example<\/h2>\n\n\n\n<p>The following program demonstrates how the <code>ManualResetEventSlim<\/code> class works:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">using <span class=\"hljs-keyword\">static<\/span> System.Console;\r\n\r\n<span class=\"hljs-keyword\">var<\/span> resetEvent = <span class=\"hljs-keyword\">new<\/span> ManualResetEventSlim(<span class=\"hljs-literal\">false<\/span>);\r\n\r\n<span class=\"hljs-keyword\">void<\/span> DoWork()\r\n{\r\n    WriteLine($<span class=\"hljs-string\">\"Thread {Thread.CurrentThread.ManagedThreadId} is waiting for the event to be signaled...\"<\/span>);\r\n\r\n    <span class=\"hljs-comment\">\/\/ Wait for the event to be signaled<\/span>\r\n    resetEvent.Wait();\r\n\r\n    WriteLine($<span class=\"hljs-string\">\"Thread {Thread.CurrentThread.ManagedThreadId} has been signaled and has resumed execution.\"<\/span>);\r\n}\r\n\r\n<span class=\"hljs-comment\">\/\/ Create a thread that wait for the event to be signaled and start it<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> t1 = <span class=\"hljs-keyword\">new<\/span> Thread(<span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> DoWork());\r\n<span class=\"hljs-keyword\">var<\/span> t2 = <span class=\"hljs-keyword\">new<\/span> Thread(<span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> DoWork());\r\n\r\nt1.Start();\r\nt2.Start();\r\n\r\n<span class=\"hljs-comment\">\/\/ Wait for 1s to let the thread runs for a while <\/span>\r\nThread.Sleep(<span class=\"hljs-number\">1000<\/span>);\r\n\r\n<span class=\"hljs-comment\">\/\/ Wait for 2s before signaling the event<\/span>\r\nWriteLine(<span class=\"hljs-string\">\"Waiting for 2 seconds before signaling the event...\"<\/span>);\r\nThread.Sleep(<span class=\"hljs-number\">2000<\/span>);\r\n\r\n\r\n<span class=\"hljs-comment\">\/\/ Signal the event<\/span>\r\nresetEvent.Set();\r\n\r\n<span class=\"hljs-comment\">\/\/ Wait for the threads to finish<\/span>\r\nt1.Join();\r\nt2.Join();\r\n\r\n\r\nWriteLine(<span class=\"hljs-string\">\"Press any key to exit.\"<\/span>);\r\nReadKey();\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/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=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">Thread <span class=\"hljs-number\">10<\/span> is waiting <span class=\"hljs-keyword\">for<\/span> the event to be signaled...\r\nThread <span class=\"hljs-number\">11<\/span> is waiting <span class=\"hljs-keyword\">for<\/span> the event to be signaled...\r\nWaiting <span class=\"hljs-keyword\">for<\/span> <span class=\"hljs-number\">2<\/span> seconds before signaling the event...\r\nThread <span class=\"hljs-number\">11<\/span> has been signaled <span class=\"hljs-keyword\">and<\/span> has resumed execution.\r\nThread <span class=\"hljs-number\">10<\/span> has been signaled <span class=\"hljs-keyword\">and<\/span> has resumed execution.\r\nPress any key to <span class=\"hljs-keyword\">exit<\/span>.\r<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/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>ManualResetEventSlim<\/code> object and initialize it with <code>false<\/code>, indicating that the event is not signaled initially:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">var<\/span> resetEvent = <span class=\"hljs-keyword\">new<\/span> ManualResetEventSlim(<span class=\"hljs-literal\">false<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, define the <code>DoWork()<\/code> method that the waiting threads will execute:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">void<\/span> DoWork()\r\n{\r\n    WriteLine($<span class=\"hljs-string\">\"Thread {Thread.CurrentThread.ManagedThreadId} is waiting for the event to be signaled...\"<\/span>);\r\n\r\n    <span class=\"hljs-comment\">\/\/ Wait for the event to be signaled<\/span>\r\n    resetEvent.Wait();\r\n\r\n    WriteLine($<span class=\"hljs-string\">\"Thread {Thread.CurrentThread.ManagedThreadId} has been signaled and has resumed execution.\"<\/span>);\r\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>DoWork()<\/code> method writes a message to the console indicating that the thread is waiting for the event to be signaled. It then calls the <code>Wait()<\/code> method of the <code>ManualResetEventSLim<\/code> object to wait for the event to be signaled.<\/p>\n\n\n\n<p>The <code>Wait()<\/code> method blocks the threads that execute the <code>DoWork()<\/code> method until the <code>ManualResetEventSlim<\/code> object becomes signaled.<\/p>\n\n\n\n<p>When the <code><code>ManualResetEventSlim<\/code><\/code> is signaled, the method resumes its execution that writes another message to the console.<\/p>\n\n\n\n<p>Third, create two threads that execute the <code>DoWork()<\/code> method and start them immediately:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-comment\">\/\/ Create threads that wait for the event to be signaled and start them<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> t1 = <span class=\"hljs-keyword\">new<\/span> Thread(<span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> DoWork());\r\n<span class=\"hljs-keyword\">var<\/span> t2 = <span class=\"hljs-keyword\">new<\/span> Thread(<span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> DoWork());\r\n\r\nt1.Start();\r\nt2.Start();\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fourth, wait for one second to leave enough time for the threads to run until the <code>Wait()<\/code> method is called:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">Thread<\/span><span class=\"hljs-selector-class\">.Sleep<\/span>(1000);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fifth, write a message to the console and wait for two seconds before signaling the event: <\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">WriteLine(<span class=\"hljs-string\">\"Waiting for 2 seconds before signaling the event...\"<\/span>);\nThread.Sleep(<span class=\"hljs-number\">2000<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Sixth, change the state of the <code><code>ManualEventResetSlim<\/code><\/code> object to be signaled by calling its <code>Set()<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-comment\">\/\/ Signal the event<\/span>\r\nresetEvent.Set();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>After this call, the threads that execute the <code>DoWork()<\/code> method resume their executions and display messages to the console.<\/p>\n\n\n\n<p>Seventh, wait for the threads to complete by calling the <code>Join()<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-comment\">\/\/ Wait for the threads to finish<\/span>\r\nt1.Join();\r\nt2.Join();\r<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, wait for the user to press any key to exit the program:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">WriteLine(<span class=\"hljs-string\">\"Press any key to exit.\"<\/span>);\nReadKey();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/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 a C# <code>ManualResetEvent<\/code> class to represent a thread synchronizing event that allows one or more threads to wait for the event to occur.<\/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=\"901\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-concurrency\/csharp-manualreseteventslim\/\"\n\t\t\t\tdata-post-title=\"C# ManualResetEventSlim\"\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=\"901\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-concurrency\/csharp-manualreseteventslim\/\"\n\t\t\t\tdata-post-title=\"C# ManualResetEventSlim\"\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>Summary: in this tutorial, you&#8217;ll learn how to use the C# ManualResetEventSlim to provide a way for threads to communicate with each other. Introduction to the C# ManualResetEventSlim class The ManualResetEventSlim class allows threads to wait for a signal from another thread before continuing execution. In other words, the ManualResetEventSlim class allows you to synchronize [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":760,"menu_order":16,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-901","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/901","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=901"}],"version-history":[{"count":4,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/901\/revisions"}],"predecessor-version":[{"id":911,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/901\/revisions\/911"}],"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=901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}