ReaderWriterLock Constructor
.NET Framework 1.1
Initializes a new instance of the ReaderWriterLock class.
[Visual Basic] Public Sub New() [C#] public ReaderWriterLock(); [C++] public: ReaderWriterLock(); [JScript] public function ReaderWriterLock();
Example
[Visual Basic] ' The complete code is located in the ReaderWriterLock ' class topic. Imports System Imports System.Threading Imports Microsoft.VisualBasic Public Class Test ' Declaring the ReaderWriterLock at the class level ' makes it visible to all threads. Private Shared rwl As New ReaderWriterLock() ' For this example, the shared resource protected by the ' ReaderWriterLock is just an integer. Private Shared resource As Integer = 0 . . . End Class 'Test [C#] // The complete code is located in the ReaderWriterLock // class topic. using System; using System.Threading; public class Test { // Declaring the ReaderWriterLock at the class level // makes it visible to all threads. static ReaderWriterLock rwl = new ReaderWriterLock(); // For this example, the shared resource protected by the // ReaderWriterLock is just an integer. static int resource = 0; . . . } [C++] // The complete code is located in the ReaderWriterLock // class topic. #using <mscorlib.dll> using namespace System; using namespace System::Threading; public __gc class Test { public: // Declaring the ReaderWriterLock at the class level // makes it visible to all threads. static ReaderWriterLock* rwl = new ReaderWriterLock(); // For this example, the shared resource protected by the // ReaderWriterLock is just an integer. static int resource = 0; . . . };
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
ReaderWriterLock Class | ReaderWriterLock Members | System.Threading Namespace | Threading | ReaderWriterLock