### ICritSec

  The ICritSec class isolates blocks of code you consider to be critical sections. Such blocks usually manipulate static data and need to do so without interruption from code that is executing in other threads.

  Objects of this class guarantee that no other thread in the current process executes between the object's construction and destruction.

  Typically, code that must execute without interruption by other threads is partitioned into a separate block, delimited by braces ({}). You create an object of this class within that block.

  Note: While the critical section is executing, avoid actions having the potential to interrupt it, such as calls to the operating system or Open Class Library. If you must preserve locks beyond the scope of a critical section object, use semaphores as implemented by the class IResourceLock.

#### AIX Considerations

  Use this class to temporarily block signals from the current process. The constructor sets the process signal mask to block all maskable signals except SIGTRAP. SIGTRAP is not masked to allow debug tracing through a critical section. The destructor restores the process signal mask to the value it had before creation of the object.

  Because signals are masked, some services might not operate correctly inside a critical section. An example of this is timer signals. If you attempt to lock an ISharedResource inside a critical section, any timeout you specify will be ineffective because the timer signal is masked.

### ICritSec - Member Functions and Data by Group

### Constructors & Destructor

Use these members to construct and destruct objects of this class. The constructor and destructor implement all of the function of this class. The constructor causes a critical section to be entered. The corresponding destructor exits the critical section.

~ICritSec

      public:
      ~ICritSec()

  Exits a critical section within the block of code where you create the critical section object and deletes the object.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

ICritSec

      public:
      ICritSec()

  Creates a critical section object and enters a critical section within the block of code where you create the object.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### Diagnostics

Use these members for diagnostic purposes. They report additional information about critical sections.

count

      public:
      static unsigned long count()

  Returns the total number of critical sections entered but not yet exited. It is equivalent to the number of ICritSec objects in existence.

Supported Platforms

  Windows | OS/2 | AIX
  Yes | Yes | Yes

### ICritSec - Inherited Member Functions and Data

#### Inherited Public Functions

  - None

#### Inherited Public Data

  - None

#### Inherited Protected Functions

  - None

#### Inherited Protected Data

  - None