.Net equivalent of CRITICAL_SECTION

  • Thread starter Thread starter Michiel
  • Start date Start date
M

Michiel

Hello,

can anyone tell me what the .Net equivalent of CRITICAL_SECTION is, c.q. how
I can get EnterCriticalSection etc to work without __gc conversion errors ?

TIA,

Michiel.
 
Yeah, but I needed a worker thread to finish some section while terminating
it from it's parent process so I think in my case it was the right solution
:)

Nadav said:
As Jochen suggested you should rather use lock then Mutex, Mutext can
cross process boundaries while lock/Monitor can't, the advantage of using a
mutex across processes doesn't come for free: any wait call being executed
on a mutex will cause the context to switch to the kernel ( even if the
state of the mutex is signaled ), CRITICAL_SECTION/lock/monitor 'cannot not'
cross process boundaries and as such will not result a context switch ( when
the object is at signaled state ) so it will not switch to the kernel.
Usage of Mutex should be done just where lock/monitor cannot be used,
using Mutex increases the amount context switches and this may harm
performance...
 
Back
Top