A
Anil TG
Hello,
Im dealing with a Client Server application with multiple Client support.
In that i'm using an integer for storing the number of clients..
On each Client connect i'm incrementing the value in a thread Safe manner like
Interlocked.Increment(ref m_ClientCount);
//Now its value is say 1 ,after increment
In this i have a class
Class ClientConnect
{
public int _clientConnect ;
public ClientConnect(ref int _clientconnect_F)
{
_clientConnect = _clientconnect_F;
}
public void change()
{
//Decrementing the value of clients..
interlocked.Decrement(ref _clientconnect_F);
//the value should have reduced from 1 to 0 rite???
}
}
im calling a thread like this to invoke the function change()
ClientConnect obj=new ClientConnect(ref m_ClientCount);
Thread CxnManager= new Thread(new ThreadStart(obj.change));
CxnManager.Start();
Now come to my problem..When i check the value of m_ClientCount after the
above operation it seem to have the same value 1.it never changes.i tried
with
_clientconnect_F--; also
instead of interlocked.Decrement(ref _clientconnect_F); inside the
change();
But no change.Since i'v passed the integer via reference ,if i make some
changes to the formal parameter it should be reflected in the actual
parameter also..rite?..
But here its not happening..Any idea?...
Im dealing with a Client Server application with multiple Client support.
In that i'm using an integer for storing the number of clients..
On each Client connect i'm incrementing the value in a thread Safe manner like
Interlocked.Increment(ref m_ClientCount);
//Now its value is say 1 ,after increment
In this i have a class
Class ClientConnect
{
public int _clientConnect ;
public ClientConnect(ref int _clientconnect_F)
{
_clientConnect = _clientconnect_F;
}
public void change()
{
//Decrementing the value of clients..
interlocked.Decrement(ref _clientconnect_F);
//the value should have reduced from 1 to 0 rite???
}
}
im calling a thread like this to invoke the function change()
ClientConnect obj=new ClientConnect(ref m_ClientCount);
Thread CxnManager= new Thread(new ThreadStart(obj.change));
CxnManager.Start();
Now come to my problem..When i check the value of m_ClientCount after the
above operation it seem to have the same value 1.it never changes.i tried
with
_clientconnect_F--; also
instead of interlocked.Decrement(ref _clientconnect_F); inside the
change();
But no change.Since i'v passed the integer via reference ,if i make some
changes to the formal parameter it should be reflected in the actual
parameter also..rite?..
But here its not happening..Any idea?...