Re: ThreadStart parameters
- From: "Alberto Poblacion" <earthling-quitaestoparacontestar@xxxxxxxxxxxxx>
- Date: Wed, 21 Mar 2007 12:23:50 +0100
"Mike P" <mike.parr@xxxxxxxxx> wrote in message news:%23C166Q6aHHA.4832@xxxxxxxxxxxxxxxxxxxxxxx
I can't find any online examples that actually show the syntax required
for passing parameters to ParameterizedThreadStart. Here is my code
that I have tried that doesn't work :
System.Threading.ThreadStart thdStart = new
System.Threading.ParameterizedThreadStart((MoveMail), new object[] {
progress, oItems, destfolder, objConn });
System.Threading.Thread thd1 = new
System.Threading.Thread(thdStart);
thd1.Start();
The ParameterizedThreadStart constructor only takes the delegate to the start procedure. The parameter itself is passed on the Start method:
System.Threading.ParameterizedThreadStart thdStart = new System.Threading.ParameterizedThreadStart(this.MoveMail);
System.Threading.Thread thd1 = new System.Threading.Thread(thdStart);
thd1.Start(new object[] {progress, oItems, destfolder, objConn });
Notice that you can only pass a SINGLE parameter of type object. You can put anyting inside an object, in this case an array of objects that contains four elements. Be sure to adjust your MailMove method accordingly (it should take only one object, not four, and then extract those four objects from inside the one that you passed).
.
- References:
- Re: ThreadStart parameters
- From: Alberto Poblacion
- Re: ThreadStart parameters
- From: Mike P
- Re: ThreadStart parameters
- Prev by Date: Re: UTF-8 encoding in AJAX web application.
- Next by Date: Creating an MTP application
- Previous by thread: Re: ThreadStart parameters
- Next by thread: Re: ThreadStart parameters
- Index(es):