在网页上,我启动了一个并行进程来执行一项长时间运行的任务,然后发送一封电子邮件以跟踪其“输出”。但是线程有时似乎在发送电子邮件之前就结束了(电子邮件是我唯一的轨道),我认为这可能与超时有关。
这里的代码:
var thread = new Thread(() =>
{
var cli = Factory.GetClient(callBack);
FedDBService.ReturnMessage msg;
try
{
msg = cli.SendFedCards(xmls.ToArray());
}
catch (Exception exe)
{
msg = new FedDBService.ReturnMessage();
msg.Error = exe.Message;
}
finally
{
cli.Close();
completion.Finished = true;
}
message = String.Format(@"{0}Ended: {1: HH:mm} {2} {3}", message, DateTime.Now,
msg.Error.Trim(' ', '\n', '\r', '\t') == "" ?
"Withouth errors" : "With errors:"
, msg.Error);
try
{
golf.classes.Mailing.Mail.sendMail(Club.ClubEmail, email, null,
"***@***.com", message, "**Subject**", false);
// this method works right
}
finally
{
Thread.Sleep(5 * 60 * 1000);
RemoveCompletion(guid);
}
});
thread.Start();
你认为这与一些超时有关吗?我可以在不让通常的请求永远运行的情况下更改它吗?