I have two scenarios and I am not sure whether to use Tasks or Threads (working with dot net Framework 4.7)
Scenario 1: Database Queries
I have a set of data base queries that I execute with SqlCommand class. I need all of the given queries to run in parallel. Queries run from 1 min to 60 minutes.
What is better in this situation? Is the Thread/Task actually "active" when it is just waiting for the query to be completed?
Scenario 2: Parsing XML
I have let's say 1000 XmlFile Objects in a List or Array. I have a set of XPath Expressions that need to be parsed from those 1000 files into a DataTable object ( for later deployment to a database ). The best scenario would be that as many of those 1000 Files get parsed in parallel.
Parsing should take not too long but definitely longer than a few seconds. I implemented this currently with Task.Run() and it takes around 90 Seconds for 1000 although i cannot really monitor how much of it is running parallel.
Are there also general rules on when to take what?
Thanks