hi,

I have a linq query which fetches a collection of datas. I want to do some functionality with each collection of data. I am

not getting how to pass var object to a thread. My linq to xml query looks like this:

XDocument readStorelist = LoadData();
            var searchResult = from stList in readStorelist.Descendants("Store")
                               select new
                               {
                                   ID = stList.Element("ID").Value,
                                   ListName = stList.Element("ListName").Value,
                                   ListDescription = stList.Element("ListDescription").Value,
                                   CreatedOn = stList.Element("CreatedOn").Value,
                                   CreatedBy = stList.Element("CreatedBy").Value
                               };

I want to do something like this but not sure how to pass strList to the thread:

foreach (var strList in searchResult)
            {

                // Here i want to pass stList to the thread
                Thread th = new Thread(new ThreadStart(DoWork));
                th.Start();
            }

Can someone plz help me on this.

Regards,
Suraj

Define a concrete type instead of allowing the query result to be anonymous.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.