M
MDB
Hello All,
I have a background thread whose job is to check for messages. In order to
set values used in the message thread I set global values. My question is,
is it okay for 2 threads to read a global value at the same time? I also
change the global value using the code below, is this alright also?
object initialvalue, newvalue;
do
{
initialvalue = myApp.Classes.Globals.gobjOutGoingCall;
newvalue = false;
}while (initialvalue != Interlocked.CompareExchange(
ref myApp.Classes.Globals.gobjOutGoingCall, newvalue, initialvalue));
I have a background thread whose job is to check for messages. In order to
set values used in the message thread I set global values. My question is,
is it okay for 2 threads to read a global value at the same time? I also
change the global value using the code below, is this alright also?
object initialvalue, newvalue;
do
{
initialvalue = myApp.Classes.Globals.gobjOutGoingCall;
newvalue = false;
}while (initialvalue != Interlocked.CompareExchange(
ref myApp.Classes.Globals.gobjOutGoingCall, newvalue, initialvalue));