PDA

View Full Version : [C#] Come faccio per Ricevere un risultato da un altro Thread


race2
05-04-2012, 12:42
Salve,
nel seguente codice che ho inserito,
vorrei ricevere la risposta di "OK" sul Metodo Start(), per gestire la condizione if(??? == "OK")

solo che devo riceverlo dal metodo Test() che si trova su di un altro Thread.....

come posso passare quella risposta ??


private void Start()
{
DataThread data = new DataThread("mario");
Thread t = new Thread(new ParameterizedThreadStart(Test));
t.Start(data);

if(??? == "OK")
{
MessageBox.Show("Tutto OK!");
}
}

private void Test(object _data)
{
string nome = ((DataThread)_data).Nome;

if (nome == "mario")
{
//Voglio comunicare a: Start() che è "OK"
//
//
}
}

class DataThread
{
private string m_nome = "";

public DataThread(string _nome)
{
m_nome = _nome;
}

public string Nome
{
get { return m_nome; }
set { m_nome = value; }
}
}

lorenzo001
05-04-2012, 13:18
Secondo me vale quanto ti hanno già detto in

http://forum.html.it/forum/showthread.php?s=&threadid=1503280

race2
05-04-2012, 14:54
ma con l'ultimo post che ho scritto cambiano le cose !!