troubleshooting Question

C# XmlTextReader gets: The thread XXXX has exited with code 259 (0x103).

Avatar of imfpalne
imfpalne asked on
7 Comments1 Solution3989 ViewsLast Modified:
Hi Experts,

I'm trying to learn and have run into an issue I'm not able to solve myself.

I'm trying to seed a list of Postal Codes into my own DB from a publicly available XML file - but when I try to run the seed, it is incredibly slow - and I randomly receive an "The thread XXXX has exited with code 259 (0x103)."

I've added some Debug statements to test if the data received is valid, and it is actually adding the data to my local DB.

What might be causing this performance issue? And what might be a better solution? (see code below)

Best regards

My code so far:
        public ActionResult Seed()
            ApplicationDbContext db = new ApplicationDbContext();

            var postalCodes = new List<PostalCode>();

            String URLString = "";

            XmlTextReader reader = new XmlTextReader(URLString);

            int fra = 0;
            int til = 0;
            String navn = "";

            while (reader.Read())
                if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "postnummer")
                    fra = reader.ReadElementContentAsInt();
                    til = reader.ReadElementContentAsInt();
                    Debug.WriteLine("fra: " + fra + " til: " + til);
                    navn = reader.ReadElementContentAsString();

                    if (til > fra)
                        for (int i = 0; i <= til - fra; i++)
                            String postnr = "" + (fra + i);
                            postalCodes.Add(new PostalCode { City = navn, PostalCodeTxt = postnr });

                        postalCodes.Add(new PostalCode { City = navn, PostalCodeTxt = "" + fra });

                    foreach (var temp in postalCodes)




            return RedirectToAction("Index");

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros