I have a multithreaded environment (web application) and I have a static Datatable (in my ConcurrentDictionary custom cache object) that I am only using for reading data from.
Is it safe to share the same static datatable to all pages that are reading in loop from this datatable? I guess accessing and reading data from rows via index should be thread safe?
What about if i access my datatable object in the following manner? Or should I use my GetFromCache() method to return datatable.copy() object to each calling thread?
DataTable dtcountrySelector = GetFromCache(some conditions); if (dtcountrySelector != null) { List<MarketPlace> convertedList = (from drCountry in dtcountrySelector.AsEnumerable() select new MarketPlace() { SiteName = Convert.ToString(drCountry["name"] ?? ""), SiteId = Convert.ToInt32(drCountry["siteid"] ?? 0), SiteCode = Convert.ToString(drCountry["sitecode"] ?? "") }).ToList(); return convertedList; Thank you.
datatable thread safety. And read learn.microsoft.com/en-us/dotnet/api/… .DataTablein cache? Why not storeconvertedListinstead?