I am using C# code and Tridion(CMS) classes to fetch data from Tridion, below is the code to get all the publications List from Tridion.

```
protected void btnPublishPublicationList_Click(object sender, EventArgs e)
    {
        try
        {
            PublicationBL pubBL = new PublicationBL();
            TridionCollection<Publication> pubAllList = pubBL.getAllPublicationList();
            List<PublicationsBO> pubBos = new List<PublicationsBO>();

            foreach (Publication pub in pubAllList)
            {
                if ((pub.Title.StartsWith("07"))||(pub.Title.StartsWith("08")))
                {
                    PublicationsBO pubBO = new PublicationsBO();
                    pubBO.publicationID = pub.ID;
                    pubBO.publicationName = pub.Title;
                    pubBos.Add(pubBO);
                }
            }

            pubBL.createPublicationListXML(pubBos);          
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }

```

In above code on the button click, I am using .net code and using Tridion class to get all the publications List as below:

```
TridionCollection<Publication> pubAllList = pubBL.getAllPublicationList();

```

I am getting my all the publications list very fast from the Tridion, however when I am going for **foreach** loop as below my process gets stuck and it takes lots of time to do this.

```
foreach (Publication pub in pubAllList)
            {
                if ((pub.Title.StartsWith("07"))||(pub.Title.StartsWith("08")))
                {
                    PublicationsBO pubBO = new PublicationsBO();
                    pubBO.publicationID = pub.ID;
                    pubBO.publicationName = pub.Title;
                    pubBos.Add(pubBO);
                }
            }

```

After debugging I found that when debugger comes to `foreach (Publication pub in pubAllList)` it is taking lots of time. I think while making the **Publication** class object is taking time and it is Tridion class.

Please suggest any other way to do this or suggest what is wrong in above code.

Thanks.