{"id":868,"date":"2023-03-10T20:06:00","date_gmt":"2023-03-10T13:06:00","guid":{"rendered":"https:\/\/csharptutorial.net\/?page_id=868"},"modified":"2023-03-10T20:06:01","modified_gmt":"2023-03-10T13:06:01","slug":"csharp-readerwriterlockslim","status":"publish","type":"page","link":"https:\/\/www.csharptutorial.net\/csharp-concurrency\/csharp-readerwriterlockslim\/","title":{"rendered":"C# ReaderWriterLockSlim"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use the C# <code>ReaderWriterLockSlim<\/code> class to control access to a shared resource.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to C# ReaderWriterLockSlim class<\/h2>\n\n\n\n<p>Sometimes, you have multiple <a href=\"https:\/\/csharptutorial.net\/csharp-concurrency\/csharp-thread\/\">threads<\/a> that read from a shared resource but only have a few threads that write to it. In this case, using the <code><a href=\"https:\/\/csharptutorial.net\/csharp-concurrency\/csharp-lock\/\">lock<\/a><\/code> statement may decrease the application&#8217;s performance. <\/p>\n\n\n\n<p>The reason is that the <code>lock<\/code> statement may block multiple threads from reading the shared resource even though these threads don&#8217;t need exclusive access. <\/p>\n\n\n\n<p>The <code>ReaderWriterLockSlim<\/code> class allows multiple threads to read from the shared resource simultaneously, but one thread to write to it at a time. Therefore, the <code>ReaderWriterLockSlim<\/code> can help improve performance in comparison with the <code>lock<\/code> statement.<\/p>\n\n\n\n<p>The <code>ReaderWriterLockSlim<\/code> has two kinds of locks:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Read lock<\/li>\n\n\n\n<li>Writer lock<\/li>\n<\/ul>\n\n\n\n<p>The <code>ReaderWriterLockSlim<\/code> allows multiple threads to acquire the read lock at the same time, as long as no thread acquired the writer lock. <\/p>\n\n\n\n<p>Also, it only allows a single thread to acquire the write lock at a time and blocks other threads from trying to acquire either the read or write lock.<\/p>\n\n\n\n<p>In practice, the <code>ReaderWriterLockSlim<\/code> is useful for scenarios where your applications have multiple readers and fewer writers.<\/p>\n\n\n\n<p>Note that the <code>ReaderWriterLockSlim<\/code> incurs some overhead. Therefore, you should use it when the benefits of concurrent access are higher than the cost of acquiring and releasing the lock.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">C# ReaderWriterLockSlim example<\/h2>\n\n\n\n<p>The following program demonstrates how to use the <code>ReaderWriterLockSlim<\/code> object to control concurrent access to a shared variable with five readers and two writers:<\/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\">using<\/span> <span class=\"hljs-keyword\">static<\/span> System.Console;\n\n<span class=\"hljs-keyword\">int<\/span> counter = <span class=\"hljs-number\">0<\/span>;\nReaderWriterLockSlim _lock = <span class=\"hljs-keyword\">new<\/span>();\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">Read<\/span>(<span class=\"hljs-params\"><\/span>)<\/span>\n{\n    <span class=\"hljs-keyword\">while<\/span> (<span class=\"hljs-literal\">true<\/span>)\n    {\n\n        <span class=\"hljs-keyword\">try<\/span>\n        {\n            _lock.EnterReadLock();\n            WriteLine(<span class=\"hljs-string\">$\"R: Thread <span class=\"hljs-subst\">{Thread.CurrentThread.ManagedThreadId}<\/span> is reading: <span class=\"hljs-subst\">{counter}<\/span>\"<\/span>);\n        }\n        <span class=\"hljs-keyword\">finally<\/span>\n        {\n            _lock.ExitReadLock();\n        }\n\n        Thread.Sleep(<span class=\"hljs-number\">500<\/span>);\n    }\n}\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">Write<\/span>(<span class=\"hljs-params\"><\/span>)<\/span>\n{\n    <span class=\"hljs-keyword\">while<\/span> (<span class=\"hljs-literal\">true<\/span>)\n    {\n        <span class=\"hljs-keyword\">try<\/span>\n        {\n            _lock.EnterWriteLock();\n            WriteLine(<span class=\"hljs-string\">$\"W: Thread <span class=\"hljs-subst\">{Thread.CurrentThread.ManagedThreadId}<\/span> is writing: <span class=\"hljs-subst\">{counter++}<\/span>\"<\/span>);\n        }\n        <span class=\"hljs-keyword\">finally<\/span>\n        {\n            _lock.ExitWriteLock();\n        }\n\n        Thread.Sleep(<span class=\"hljs-number\">2000<\/span>);\n    }\n}\n\n\n<span class=\"hljs-comment\">\/\/ create 5 reader threads<\/span>\n<span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">int<\/span> i = <span class=\"hljs-number\">0<\/span>; i &lt; <span class=\"hljs-number\">5<\/span>; i++)\n{\n    <span class=\"hljs-keyword\">new<\/span> Thread(() =&gt; Read()).Start();\n}\n\n<span class=\"hljs-comment\">\/\/ create 2 writer threads<\/span>\n<span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">int<\/span> i = <span class=\"hljs-number\">0<\/span>; i &lt; <span class=\"hljs-number\">2<\/span>; i++)\n{\n    <span class=\"hljs-keyword\">new<\/span> Thread(() =&gt; Write()).Start();\n}<\/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>How it works.<\/p>\n\n\n\n<p>First, declare an integer variable <code>counter<\/code>:<\/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-keyword\">int<\/span> counter = <span class=\"hljs-number\">0<\/span>;<\/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>Second, create a new <code>ReaderWriterLockSlim<\/code> object called <code>_lock<\/code>:<\/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\">ReaderWriterLockSlim _lock = <span class=\"hljs-keyword\">new<\/span>();<\/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>Third, define the <code>Reader()<\/code> method that acquires a read lock on the <code>_lock<\/code> object by calling the <code>EnterReadLock()<\/code> method in the <code>try<\/code> block:<\/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\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">Read<\/span>(<span class=\"hljs-params\"><\/span>)<\/span>\n{\n    <span class=\"hljs-keyword\">while<\/span> (<span class=\"hljs-literal\">true<\/span>)\n    {\n\n        <span class=\"hljs-keyword\">try<\/span>\n        {\n            _lock.EnterReadLock();\n            WriteLine(<span class=\"hljs-string\">$\"R: Thread <span class=\"hljs-subst\">{Thread.CurrentThread.ManagedThreadId}<\/span> is reading: <span class=\"hljs-subst\">{counter}<\/span>\"<\/span>);\n        }\n        <span class=\"hljs-keyword\">finally<\/span>\n        {\n            _lock.ExitReadLock();\n        }\n\n        Thread.Sleep(<span class=\"hljs-number\">500<\/span>);\n    }\n}<\/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>The <code>Read()<\/code> method displays the value of the <code>counter<\/code> variable.<\/p>\n\n\n\n<p>Also, it releases the read lock on the <code>_lock<\/code> object in the <code>finally<\/code> block by calling the <code>ExitReadLock()<\/code> method.<\/p>\n\n\n\n<p>The <code>Read()<\/code> method delays for 500 milliseconds, which is a half of second.<\/p>\n\n\n\n<p>Fourth, define the <code>Write<\/code> method that increases the shared variable <code>counter<\/code>:<\/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\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">Write<\/span>(<span class=\"hljs-params\"><\/span>)<\/span>\n{\n    <span class=\"hljs-keyword\">while<\/span> (<span class=\"hljs-literal\">true<\/span>)\n    {\n        <span class=\"hljs-keyword\">try<\/span>\n        {\n            _lock.EnterWriteLock();\n            WriteLine(<span class=\"hljs-string\">$\"W: Thread <span class=\"hljs-subst\">{Thread.CurrentThread.ManagedThreadId}<\/span> is writing: <span class=\"hljs-subst\">{counter++}<\/span>\"<\/span>);\n        }\n        <span class=\"hljs-keyword\">finally<\/span>\n        {\n            _lock.ExitWriteLock();\n        }\n\n        Thread.Sleep(<span class=\"hljs-number\">2000<\/span>);\n    }\n}<\/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 <code>Write<\/code> method acquires a write lock on the <code>_lock<\/code> object in the <code>try<\/code> block by calling the <code>EnterWriteLock()<\/code> method. <\/p>\n\n\n\n<p>After that, it increases the <code>counter<\/code> by one and displays the <code>counter<\/code> value to the console. The <code>Write<\/code> method releases the write lock in the <code>finally<\/code> block by calling the <code>ExitWriteLock()<\/code> method.<\/p>\n\n\n\n<p>The <code>Write<\/code> method has a delay of 2000 milliseconds, which is 2 seconds.<\/p>\n\n\n\n<p>Fifth, create two reader threads and two writer threads. The reader threads execute the <code>Read<\/code> method while the writer threads execute the <code>Write<\/code> method.<\/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-comment\">\/\/ create 5 reader threads<\/span>\n<span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">int<\/span> i = <span class=\"hljs-number\">0<\/span>; i &lt; <span class=\"hljs-number\">5<\/span>; i++)\n{\n    <span class=\"hljs-keyword\">new<\/span> Thread(() =&gt; Read()).Start();\n}\n\n<span class=\"hljs-comment\">\/\/ create 2 writer threads<\/span>\n<span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">int<\/span> i = <span class=\"hljs-number\">0<\/span>; i &lt; <span class=\"hljs-number\">2<\/span>; i++)\n{\n    <span class=\"hljs-keyword\">new<\/span> Thread(() =&gt; Write()).Start();\n}<\/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>Here&#8217;s a sample output of the program:<\/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\">R: Thread <span class=\"hljs-number\">9<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">0<\/span>\nR: Thread <span class=\"hljs-number\">8<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">0<\/span>\nR: Thread <span class=\"hljs-number\">10<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">0<\/span>\nR: Thread <span class=\"hljs-number\">11<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">0<\/span>\nW: Thread <span class=\"hljs-number\">13<\/span> <span class=\"hljs-keyword\">is<\/span> writing: <span class=\"hljs-number\">0<\/span>\nW: Thread <span class=\"hljs-number\">12<\/span> <span class=\"hljs-keyword\">is<\/span> writing: <span class=\"hljs-number\">1<\/span>\nR: Thread <span class=\"hljs-number\">7<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">10<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">11<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">7<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">9<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">8<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">7<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">11<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">8<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">9<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">10<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">9<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">8<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">11<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">10<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nR: Thread <span class=\"hljs-number\">7<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">2<\/span>\nW: Thread <span class=\"hljs-number\">13<\/span> <span class=\"hljs-keyword\">is<\/span> writing: <span class=\"hljs-number\">2<\/span>\nW: Thread <span class=\"hljs-number\">12<\/span> <span class=\"hljs-keyword\">is<\/span> writing: <span class=\"hljs-number\">3<\/span>\nR: Thread <span class=\"hljs-number\">8<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">9<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">9<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">10<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">7<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">11<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">8<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">8<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">11<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">7<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">10<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\nR: Thread <span class=\"hljs-number\">9<\/span> <span class=\"hljs-keyword\">is<\/span> reading: <span class=\"hljs-number\">4<\/span>\n...<\/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>To terminate the program, you need to close it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use C# <code>ReaderWriterLockSlim<\/code> to allow multiple threads to read from the shared resource simultaneously, but one thread to write to it at a time.<\/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=\"868\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-concurrency\/csharp-readerwriterlockslim\/\"\n\t\t\t\tdata-post-title=\"C# ReaderWriterLockSlim\"\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=\"868\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-concurrency\/csharp-readerwriterlockslim\/\"\n\t\t\t\tdata-post-title=\"C# ReaderWriterLockSlim\"\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 will learn how to use the C# ReaderWriterLockSlim class to control access to a shared resource.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":760,"menu_order":13,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-868","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/868","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=868"}],"version-history":[{"count":4,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/868\/revisions"}],"predecessor-version":[{"id":873,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/868\/revisions\/873"}],"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=868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}