|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
[C#] Come faccio per Ricevere un risultato da un altro Thread
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 ?? Codice:
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; }
}
}
|
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Jul 2008
Città: Roma
Messaggi: 542
|
|
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
ma con l'ultimo post che ho scritto cambiano le cose !!
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 09:25.



















