本文介绍了使用线程启动时System.outofmemoryexception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用threds来处理xml文件

for(i = 0; i< 200; i ++)

{

Thread thread1 = new Thread(()=> ProcessParadotProspect(dsXMLData,strFileName));

thread1.Start();



Thread thread2 = new Thread(()=> ProcessVistorActivity(dsXMLData,prospect_id,strFileName));

thread2.Start();



Thread thread3 = new Thread(()=> ProcessListSubscription(dsXMLData,prospect_id,strFileName));

thread3.Start();

}

但2分钟后System.OutOfMemoryException即将到来



请告诉我如何解决



我尝试了什么:



我在谷歌搜索中尝试过这么多帖子但是没有得到正确的解决方案请帮忙解决这个问题

I am using threds for processing xml files
for(i=0;i<200;i++)
{
Thread thread1 = new Thread(() => ProcessParadotProspect(dsXMLData, strFileName));
thread1.Start();

Thread thread2 = new Thread(() => ProcessVistorActivity(dsXMLData, prospect_id, strFileName));
thread2.Start();

Thread thread3 = new Thread(() => ProcessListSubscription(dsXMLData, prospect_id, strFileName));
thread3.Start();
}
but after 2 minutes System.OutOfMemoryException is coming

please tell me how to resolve

What I have tried:

ihave tried so many posts in google search but not getting correct solution please help out in this regard

推荐答案



for(i=0;i<200;i++)
{
    Task.Factory.StartNew( () => {
        ProcessParadotProspect(dsXMLData, strFileName);
        ProcessVistorActivity(dsXMLData, prospect_id, strFileName);
        ProcessListSubscription(dsXMLData, prospect_id, strFileName)
    });
}


这篇关于使用线程启动时System.outofmemoryexception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 17:11