D
Davide Villa via .NET 247
May I have anyone help?
I have a class with a property which could be accessed by different threads.
Can I put a lock block or a mutex in a get/set property to allow only a thread at time access?
The code I'm thinking sounds like this:
public class Dispatcher(){
private int p_State;
public State {
set{
int l_State;
lock(this){
l_State=p_State;
}
return l_State;
}
get{
lock(this){
p_State=value;
}
}
}
}
Thnx in advice to anyone helps me!
I have a class with a property which could be accessed by different threads.
Can I put a lock block or a mutex in a get/set property to allow only a thread at time access?
The code I'm thinking sounds like this:
public class Dispatcher(){
private int p_State;
public State {
set{
int l_State;
lock(this){
l_State=p_State;
}
return l_State;
}
get{
lock(this){
p_State=value;
}
}
}
}
Thnx in advice to anyone helps me!