G
Guest
I have a class named AccessClass to access a legacy system.
In a webform i instanciate an AccessClass object named myAccess
and i call a method : myAccess.accessmethod()
I want to insure that no two webforms run simultaneouslly the code in
accessMethod()
So the code of accessMethode() is
void accessMethod()
{
lock(this)
{
... code ...
}
}
My questions are :
Is this insure my goal ? Is my code a critical section for all clients ?
I have a doubt because each webform has his proper instance of AccessClass.
If two webforms instanciate an AccessClass object and call AccessMethod() at
the same time, there is two different objects so if the critical section is
relative to the object there is no critical section among all clients.
If my solution is bad, an other idea is to pass a reference to the
"Application" object to myMethod and to use it as the lock parameter. Indeed
"Application" is shared between all clients.
Is it a better idea ?
If not, what is the solution ?
Thanks,
Christian
In a webform i instanciate an AccessClass object named myAccess
and i call a method : myAccess.accessmethod()
I want to insure that no two webforms run simultaneouslly the code in
accessMethod()
So the code of accessMethode() is
void accessMethod()
{
lock(this)
{
... code ...
}
}
My questions are :
Is this insure my goal ? Is my code a critical section for all clients ?
I have a doubt because each webform has his proper instance of AccessClass.
If two webforms instanciate an AccessClass object and call AccessMethod() at
the same time, there is two different objects so if the critical section is
relative to the object there is no critical section among all clients.
If my solution is bad, an other idea is to pass a reference to the
"Application" object to myMethod and to use it as the lock parameter. Indeed
"Application" is shared between all clients.
Is it a better idea ?
If not, what is the solution ?
Thanks,
Christian