ASP.NET中的多线程问题

发布于 2024-12-18 19:56:27 字数 1883 浏览 0 评论 0原文

我的服务器上托管了一个应用程序。该应用程序向用户列表发送电子邮件。假设该列表有 10000 个用户。我将列表分为三个部分,并将每个部分分配给一个单独的线程来发送电子邮件。问题是当我在 Visual Studio 中运行该应用程序并运行该应用程序时,它会将电子邮件发送到我创建的所有 3 个列表,但是当我在本地电脑上远程浏览该应用程序时。电子邮件未发送。 该代码位于我创建的用于发送电子邮件的网络服务内。这是我的代码:

    ArrayList thList1 = new ArrayList(); 
    ArrayList thList2 = new ArrayList(); 
    ArrayList thList3 = new ArrayList(); 
    ArrayList thListId1 = new ArrayList(); 
    ArrayList thListId2 = new ArrayList(); 
    ArrayList thListId3 = new ArrayList(); 
    int countList = arlistuid.Count / 3; 
    int count; 
    for (count = 0; count < arlistuid.Count; count++) 
    { 
    if (count < countList)
    { 
       thList1.Add(arlistuid[count]); 
       thListId1.Add(arlistid[count]); 
    } 
    else if (count >= countList && (count < countList + countList)) 
    { 
       thList2.Add(arlistuid[count]); 
       thListId2.Add(arlistid[count]); 
    }
    else 
    { 
        thList3.Add(arlistuid[count]); 
        thListId3.Add(arlistid[count]); 
    }

   if (thList1.Count > 0)
   {
       object thdargs = new object[2] { thList1, thListId1 };
       Thread thd1 = new Thread(new ParameterizedThreadStart(SplitListEmail));
       thd1.IsBackground = true;
       thd1.Name = "Thread1";
       thd1.Start(thdargs);
   }
   if (thList2.Count > 0)
   {
       object thd2args = new object[2] { thList2, thListId2 };
       Thread thd2 = new Thread(new ParameterizedThreadStart(SplitListEmail));
       thd2.IsBackground = true;
       thd2.Name = "Thread2";
       thd2.Start(thd2args);
   }
   if (thList3.Count > 0)
   {        
       object thd3args = new object[2] { thList3, thListId3 };
       Thread thd3 = new Thread(new ParameterizedThreadStart(SplitListEmail));
       thd3.IsBackground = true;
       thd3.Name = "Thread3";
       thd3.Start(thd3args);
   }

任何人都可以帮助我问题是什么以及如何解决它吗?

I have an application hosted on my server. this application sends emails to list of users. lets say the list have 10000 users. i divide the list into three parts and assign each to a seperate thread to send emails. The issue is when i the application in visual studio and run the application, it sends the emails to all the 3 list i have created, but when i browse the application remotely on my local pc. the emails is not sending.
The code is inside a webservice i have created to send emails.Here is my code:

    ArrayList thList1 = new ArrayList(); 
    ArrayList thList2 = new ArrayList(); 
    ArrayList thList3 = new ArrayList(); 
    ArrayList thListId1 = new ArrayList(); 
    ArrayList thListId2 = new ArrayList(); 
    ArrayList thListId3 = new ArrayList(); 
    int countList = arlistuid.Count / 3; 
    int count; 
    for (count = 0; count < arlistuid.Count; count++) 
    { 
    if (count < countList)
    { 
       thList1.Add(arlistuid[count]); 
       thListId1.Add(arlistid[count]); 
    } 
    else if (count >= countList && (count < countList + countList)) 
    { 
       thList2.Add(arlistuid[count]); 
       thListId2.Add(arlistid[count]); 
    }
    else 
    { 
        thList3.Add(arlistuid[count]); 
        thListId3.Add(arlistid[count]); 
    }

   if (thList1.Count > 0)
   {
       object thdargs = new object[2] { thList1, thListId1 };
       Thread thd1 = new Thread(new ParameterizedThreadStart(SplitListEmail));
       thd1.IsBackground = true;
       thd1.Name = "Thread1";
       thd1.Start(thdargs);
   }
   if (thList2.Count > 0)
   {
       object thd2args = new object[2] { thList2, thListId2 };
       Thread thd2 = new Thread(new ParameterizedThreadStart(SplitListEmail));
       thd2.IsBackground = true;
       thd2.Name = "Thread2";
       thd2.Start(thd2args);
   }
   if (thList3.Count > 0)
   {        
       object thd3args = new object[2] { thList3, thListId3 };
       Thread thd3 = new Thread(new ParameterizedThreadStart(SplitListEmail));
       thd3.IsBackground = true;
       thd3.Name = "Thread3";
       thd3.Start(thd3args);
   }

Can anybody help me what is the issue and how to resolve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文