Thread parametrico..

lunedì 20 luglio 2009 - 12.38

Superpippo1980 Profilo | Junior Member

Ciao a tutti.
Nei miei servizi NT windows ho sempre utilizzato
thread richiemando funzioni non parametriche:

private void ProgressFormPrice_Load(object sender, System.EventArgs e)
{

_T = new Thread(new System.Threading.ThreadStart(DoJob));
this._T.Start();
}
private void DoJob()
{ .....
}


Ho l'esigenza adesso di utilizzare ilk thread in una funzione fatta così:

private void GeneraAvvisi(cl_Regole Regola, cl_Numero Numero, string s1, DateTime data, DateTime data1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, bool ok, string s9)
{
.....
}

Ho provato a richiamarla iun questo modo:
_T = new Thread(new System.Threading.ThreadStart(GeneraAvvisi));
this._T.Start(Regola, num, nome, data, dataevento, msg, Messaggiomsg, MessaggioGruppi, Messaggionumeri, Messaggiodopo, MessaggioPr, s8, ok, s9);

Ma mi dice che:

Il metodo 'SchedulerSrv.SchedulerSrv.GeneraAvvisi(cl_Regole Regola, cl_Numero Numero, string s1, DateTime data, DateTime data1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, bool ok, string s9)
' non corrisponde al delegato 'void System.Threading.ThreadStart()'.


Che devo fare?????

Grazie a tutti



tonyexpo Profilo | Senior Member


Ciao

puoi utilizzare solo metodi con un unico parametro tipo object da passare al costruttore di un thread:


static void Main(string[] args) { Thread t = new Thread(chiamami); t.Start(new cParametri()); } static void chiamami(object o) { cParametri c = (cParametri) o; } class cParametri { string a; int b; double c; }
Antonio Esposito
MCTS .NET 3.5 WCF
MCTS .NET 3.5 Windows Forms
MCTS .NET 2.0 Distributed applications
MCP
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5