Dynamic Multi-threading lock with while loop
Just one question : when do you release the key ?
Suppose twice the same key is called almost simultaneously, so that one of the two threads involved will go through the 


  Thread.Sleep(50) ;


line ..
The first thread enters the lock, the key is added to the dictionary, fine.
At almost the same time the other thread enters the lock, find the key already there and go sleeping.
When the first thread exit, if you don't release the key, the other thread will wait a long long time ..
May be something like  

_lockByKeys.Remove(key)


is enough to solve this one.

After this, reading again this code, I found a dictionary, a lock and a monitor. I'm quite sure that a ConcurrentDictionary could make the same job, with a cleaner code if not faster.

Lastly, 100 threads with some of them blocked could become a production nightmare if too much keys have the same value.

Hope this help !