异步发送Email
总线程数=当前main线程+基它并发线程
eventTarget与formValidator
==========================
protected void btnSubmit_Click(object sender, EventArgs e)
{
MemberInfo info = this.GetInfo();
this.Validate(info);
Thread dntAsync = new Thread(new ParameterizedThreadStart(this.ExcuteDNT));
dntAsync.Start(info);
//dntAsync。jion()解决
//或者 ManualResetEvent allDone = new ManualResetEvent(false);
const string subject = "会员注册信息";
string mailBody = this.GetMailBody(info.MemberId, info.MemberName, info.Password);
EmailProxy.Send(info.Email, subject, mailBody, true);
MEMBER.Add(info);
FormsAuthentication.SetAuthCookie(info.MemberId, false);
string returnUrl = Request.QueryString["returnUrl"];
if (string.IsNullOrEmpty(returnUrl))
{
returnUrl = "RegOk.aspx";
}
Response.Redirect(returnUrl);
}
public void ExcuteDNT(object data)
{
MemberInfo info = data as MemberInfo;
ISynchHelper dntHelper = new SynchDNTHelper();
dntHelper.Register(info.MemberId, info.Password, info.Email);
dntHelper.UpdateInfo(info.MemberId);
//可能必须要当前线程
dntHelper.Login(info.MemberId);
}
================================
formValidator必须submit按钮
asp.net必须是submit,没有则需要eventTarget
disabled是true则不能提交,且不能发现服务端事件(eventTarget)