事件类型: 错误
事件来源: ASP.NET 4.0.30319.0
事件种类: 无
事件 ID: 1325
日期: 2010-11-10
事件: 14:34:47
用户: N/A
计算机:
描述:
发生了未经处理的异常,已终止进程。Application ID: /LM/W3SVC/709485233/RootProcess ID: 5556Exception: System.Net.Mail.SmtpExceptionMessage: 发送邮件失败。StackTrace: 在 Common.MailHelper.SendMail(String server, String username, String password, String toaddr, String titel, String body) 位置 E:\Common\MailHelper.cs:行号 145
在 Web.Admin.module.EmailSend.<>c__DisplayClass16.<btnSend_Click>b__1() 位置 E:\module\EmailSend.aspx.cs:行号 100
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.runTryCode(Object userData)
在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()InnerException: System.Net.WebExceptionMessage: 无法连接到远程服务器StackTrace: 在 System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
在 System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
在 System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
在 System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
在 System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
在 System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
在 System.Net.Mail.SmtpClient.GetConnection()
在 System.Net.Mail.SmtpClient.Send(MailMessage message)InnerException: System.Net.Sockets.SocketExceptionMessage: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。StackTrace: 在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
事件来源: ASP.NET 4.0.30319.0
事件种类: 无
事件 ID: 1325
日期: 2010-11-10
事件: 14:34:47
用户: N/A
计算机:
描述:
发生了未经处理的异常,已终止进程。Application ID: /LM/W3SVC/709485233/RootProcess ID: 5556Exception: System.Net.Mail.SmtpExceptionMessage: 发送邮件失败。StackTrace: 在 Common.MailHelper.SendMail(String server, String username, String password, String toaddr, String titel, String body) 位置 E:\Common\MailHelper.cs:行号 145
在 Web.Admin.module.EmailSend.<>c__DisplayClass16.<btnSend_Click>b__1() 位置 E:\module\EmailSend.aspx.cs:行号 100
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.runTryCode(Object userData)
在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()InnerException: System.Net.WebExceptionMessage: 无法连接到远程服务器StackTrace: 在 System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
在 System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
在 System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
在 System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
在 System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
在 System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
在 System.Net.Mail.SmtpClient.GetConnection()
在 System.Net.Mail.SmtpClient.Send(MailMessage message)InnerException: System.Net.Sockets.SocketExceptionMessage: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。StackTrace: 在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
我用我自己的QQ邮箱 发了几个就不行了 后来我邮箱都上不去了.
是他们设置了不允许频繁发送的缘故
protected void Page_Load(object sender, EventArgs e)
{
System.Threading.WaitCallback waitCallback = new WaitCallback(MyWork);
ThreadPool.QueueUserWorkItem(waitCallback, "第一个线程"); }
public static void MyWork(object state)
{
Console.WriteLine("线程现在开始启动…… {0}", (string)state);
Thread.Sleep(10000);
Console.WriteLine("运行结束…… {0}", (string)state); }
2.
Thread th = new Thread(delegate()
{
}
});
th.Start();
while (true)
{
if (th.ThreadState != ThreadState.Stopped)
continue;
break;
}
th.Abort(); 这2种方式是不是效果都是一样的 那种效果比较好??
{
System.Threading.WaitCallback waitCallback = new WaitCallback(MyWork);
ThreadPool.QueueUserWorkItem(waitCallback, "第一个线程");
ThreadPool.QueueUserWorkItem(waitCallback, "第个线程");
}
public static void MyWork(object state)
{
//
}
能说说上面俩个线程的优缺点吗?
使用ThreadPool类比Thread类创建线程简单的多。但是,在确定是用ThreadPool类还是Thread类创建线程时,考虑如下问题:在达到如下目标时,应使用ThreadPool类:要以最简单的方式创建和删除线程;应用程序使用线程的性能要优先考虑。在达到如下目标时,应使用Thread类:要控制所创建线程的优先级;希望所使用的线程维护其标识,该标识要与线程一起进行各种操作,经过许多不同的时间段;所使用的线程的寿命较长。