I have a simple code, which send from server to clients value to count. This loop count for 9 value, from 1 to 9. Everything work good for 1,3 or 9 clients. But for other number of clients when i_wiersz has value 9 and foreach loop want sent something to another client server break down. Ho make, to work with any one numbers of clients?
I try put inside foreach loop:
if(i_wiersz == 9)
break;
but a get an error: Error
Control cannot leave the body of an anonymous method or lambda expression
My code:
bool spr_wiersz(int wiersz, int kolumna) //chck_roow(int roow, int column)
{
wys_tab();
int i_wiersz = 0;
bool[] result = new bool[9];
while (i_wiersz < 9)
{
subscribers.ForEach(delegate(ImessageCallback callback)
{
if (((ICommunicationObject)callback).State == CommunicationState.Opened)
{
result[i_wiersz] = callback.spr_wiersz(wiersz, kolumna, i_wiersz);
i_wiersz++;
}
});
for (int j = 0; j < i_wiersz; j++)
{
if (result[j] == false)
{
return false;
}
}
}
return true;
}