0

I have the following peice of code:

    private static void FetchAllDataForAllNodesInCache()
    {
        var tasksList = Cache.TreeNodeItemsCollection.Select(nodeToEnrich => new Task(() => InsertQueuesIntoNode(nodeToEnrich))).ToList();

        var count = tasksList.Count;
    }

    private static void InsertQueuesIntoNode(TreeNode toEnrich)
    {
        // blagh do something?
    }

My question is, do I need to use a Take or Try Take method when setting up a new task or is the above fine? I mean, don't I need to remove my item safely from the collection and then add it back in again when the task has completed safely. The only gurantee I can provide for anyone who wants to answer my question is that, no two tasks will be working with the same node from 'Cache.TreeNodeItemsCollection'.

I am yet to add in some code to kick off the tasks but that will be added once I know of my current set-up is fine or not?

IbrarMumtaz
  • 4,235
  • 7
  • 44
  • 63

0 Answers0