How can create this thread? help me ,thank thank thank

Q

qushui_chen

my write code is(i know that is error),how can I do?:
-------------------------------------------------------------------
ThreadArray[m]=new Thread(new ThreadStart(this.send_write_log(
ec_send_email, ec_send_name, es_email, smtp_server, email_format,
et_subject, et_content, esl_id, et_id,es_id,esl_type)));
ThreadArray[m].IsBackground=true;
ThreadArray[m].Start();

function is:
--------------------------------------------------------------------
public void send_write_log(string ec_send_email,string ec_send_name,string
es_email,string smtp_server,bool email_format,string et_subject,string
et_content,int esl_id,int et_id,int es_id,int esl_type)
{
//send Mail
string send_log="";
string code_no;
bool send_flag=false;

if(esmtp.Send(ec_send_email,ec_send_name,es_email,"",smtp_server,email_forma
t,et_subject,et_content))
{
send_log=esmtp.Logs.ToString();
send_log=cm.getEndLine(send_log); //Get End Line String
code_no=cm.getCodeNo(send_log);
send_flag=true;
}
else
{
send_log=esmtp.ErrorMessage;
code_no=cm.getErrorCodeNo(send_log);
}
send_log=cm.limitStringLength(send_log); //fix string "'" and length
int code_no_int=Convert.ToInt32(code_no);


rtb_info.SelectionColor=Color.Green;
//rtb_info.AppendText("Mail Server:"+dns_mx+"\r\n");
rtb_info.AppendText("> "+es_email+" have sent!
"+send_flag.ToString()+"\r\n");
//rtb_info.AppendText(">"+send_log);
//rtb_info.AppendText(">"+send_log.Length.ToString());


if(esl_type!=2)
{
// write the Email send state to send log
rtb_info.AppendText("> write the "+es_email+ " send state to subscribe
send log! \r\n");

e_db_manage.addNewSubscribSendLog(esl_id,et_id,es_id,es_email,code_no_int,se
nd_log);
}
else //on resend mail then update log
{
// write the Email send state to send log
rtb_info.AppendText("> Upstate the "+es_email+ " send state to subscribe
send log! \r\n");

e_db_manage.updateSubscribSendLog(esl_id,et_id,es_id,code_no_int,send_log);
}
}
 
M

Miha Markic

Hi qushui,

ThreadStart is a parameterless delegate thus accepting only parameterless
methods.
IOW - you can't pass arguments.
Arguments should be passed in another way. One way would be to use global
varaibles.
Other way would be to put thread method into another class and put arguments
into this class' fields and then start the method.
Of course, there are other ways.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top