J
Jeff Johnson
With all the stuff I've read on threading I ought to know this, but I'm
going to ask anyway.
I have a class which can have multiple instances running one different
threads. Each instance may need to update a static dictionary in the same
class. Is the preferred way on synchronizing access to this dictionary to do
something like this:
private static Dictionary<string, string> _whateverDict = new
Dictionary<string, string>();
private static object _globalLockObject = new object();
private void SomeMethod()
{
lock (_globalLockObject)
{
// Access dictionary here
}
}
going to ask anyway.
I have a class which can have multiple instances running one different
threads. Each instance may need to update a static dictionary in the same
class. Is the preferred way on synchronizing access to this dictionary to do
something like this:
private static Dictionary<string, string> _whateverDict = new
Dictionary<string, string>();
private static object _globalLockObject = new object();
private void SomeMethod()
{
lock (_globalLockObject)
{
// Access dictionary here
}
}