Hi,
I simply if it is an okay practise to use lock objects in functions which is not a background thread.
If we assume that the code that exist in those lock object is no more than just say 5-10 lines of code,
which takes less than 1 milliseconds to execute?
Also we would assume that those lock objects will not be embedded anywhere where deadlocks can occur?
object lockObject = new object();
void isnotbackgroundthread1()
{
lock (lockObject)
{
//5 lines of code
}
}
void isnotbackgroundthread2()
{
lock (lockObject)
{
//5 lines of code.
}
}