2
I have the following code:
MinhaClasse[] obj = new MinhaClasse[QtdUsuario];
Thread th;
For(int i = 0; i < QtdUsuario; i++)
{
obj[i] = new MinhaClasse();
th = new Thread(new ParameterizedThreadStart(Metodo));
th.SetApartmentState(ApartmentState.STA);
th.IsBackground = true;
th.Start(obj[i]);
}
Each object shows an image on the screen, and these images keep moving on the screen.
Ex: if the user sets the variable QtdUsuario
for 5
i will have 5 objects and each object in a thread. Then on the screen I will have 5 images moving randomly.
My goal is to:
How can I identify possible collisions between these objects (images)?
And how can I define individual values for each object ?
Ex: user will say that image 1 will have idade
= 5, and decreases and increases
that one idade
?
Perhaps it would be better to have only one thread. As you can see most of the code has synchronization and so will not take advantage of the parallelism
– Bruno Costa