您的位置:程序门 -> .net技术 -> c#



多线程下载邮件


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


多线程下载邮件
发表于:2007-03-01 19:18:17 楼主
在邮件服务器上,多线程下载多个用户email地址上的邮件时,提示错误:不允许对非连接的套接字执行此操作.

public   class   download  
{
public   downloademail   de;
public   datarow   dr;

public   download(){}
 
    public   void   downloading(   )
  {
if(de   !=   null)
de(dr);
      }
}  
  private   void   frmreceivedailog_load(object   sender,   system.eventargs   e)
{
_popclient.authenticationbegan+=new   eventhandler(popclient_authenticationbegan);
_popclient.authenticationfinished+=new   eventhandler(popclient_authenticationfinished);
_popclient.communicationbegan+=new   eventhandler(popclient_communicationbegan);
_popclient.communicationoccured+=new   eventhandler(popclient_communicationoccured);
_popclient.communicationlost+=new   eventhandler(popclient_communicationlost);
_popclient.messagetransferbegan+=new   eventhandler(popclient_messagetransferbegan);
_popclient.messagetransferfinished+=new   eventhandler(popclient_messagetransferfinished);

// //   1-------
//   _thread=new   thread(new   threadstart(downloademails));
// //_thread.isbackground=true;
// _thread.start();
 
  if(_drcurrentmailaccount   !=   null)
{
//创建一个download的实例
download   _download   =   new   download();
//向这个download的实例传递dr行
_download.dr   =   _drcurrentmailaccount;
_download.de   =new   downloademail(downloademails);
//初始化一个线程实例
  _thread=   new   thread   (   new   threadstart   (   _download.downloading   )   )   ;
//启动线程
   _thread.start   (   )   ;
}
else
{
//   2----------
datatable   dtmailaccountall   =   _mailaccount.loaddata();
int   _threadnum   =   dtmailaccountall.rows.count;
  //创建多个thread实例
  thread[]   mythread   =   new   thread   [   _threadnum   ]   ;  
int   k;
  for(   k=0   ;   k   <   mythread.length   ;   k   ++)
{
//创建一个download的实例
download   _download   =   new   download();
  _download.dr   =   dtmailaccountall.rows[k];
  _download.de   =new   downloademail(   downloademails   );
mythread[k]   =   new   thread   (   new   threadstart   (   _download.downloading   )   )   ;
    }
for(   int   i=   0;i <   mythread.length;   i++)
{
  mythread[i].start();
   
  }

 
}
      }

private   void   downloademails(datarow   drcurrentmailaccount)
{
                                          ...................
                                      }


请大虾们看看,谢谢了.
发表于:2007-03-01 20:19:031楼 得分:0
你需要贴的是异常详细信息而不是代码.

贴调用堆栈和其他异常数据


快速检索

最新资讯
热门点击