I need to lock a section of code by string. Of course the following code is hideously unsafe:
lock(\"http://someurl\") { //bla }
So I\'
Now I have the same issue. I decided to use simple solution: to avoid deadlocks create a new string with fixed unique prefix and use it as a lock object:
lock(string.Intern("uniqueprefix" + url)) { // }