How do i run max n threads in a c# code block?
I’ll like something easy and short like this pseudocode
lock (this, 5)
{
//do some work
}
EDIT: This is not a shared memory, race condition thing. The problem is that I have alot of threads. But I found out the a resource used in one part of the code is failing when used too much in parallel. I could use a objecpool, but I hoped i could do it even more easy.
Use a Semaphore