locked
PLINQ and TPL RRS feed

  • Question

  • I have been converting my LINQ queries to PLINQ with use of the AsParallel() function - I break into the debugger and expect to see "worker" tasks in the  "Parallel Tasks" debug window - instead I see worker threads in the Thread debugging window - why is this? doesnt PLINQ use the Task Parallel Library?


    jaydd
    Wednesday, September 2, 2009 12:53 PM

Answers

  • Hi jaydd

    I can try to repro your issue and see what is wrong.

    Do you have sample code you can share including where to place the breakpoint please?

    Cheers
    Daniel
    --
    http://www.danielmoth.com/Blog
    http://www.danielmoth.com/Blog/
    • Marked as answer by jaydd Thursday, September 3, 2009 12:53 PM
    Wednesday, September 2, 2009 5:44 PM
  • Hi Daniel,

    My bad; I had the breakpoint at the wrong place - here is my code out of context - after I placed a breakpoint at the "SaveDocument()" line - i could see the tasks in the tasks window ... the tasks didnt begin till the Aggregate forced the enumeration... Thanks

    var gamefilecounts = allGames.AsParallel().
                        Select(game => game.GameFiles.
                            Select(locator => GetXMLFromFileUri(locator)). 
                            Select(n => TransformXml(n)).
                            Aggregate(
                                0,
                                (int count, XElement n) =>
                                {
                                    //count each successive file as it is processed
                                    SaveDocument(n);
                                    return ++count;
                                }));

    int totalcount = gamefilecounts.Aggregate(0, (acc, indivcount) => acc += indivcount);

    jaydd
    • Marked as answer by jaydd Thursday, September 3, 2009 12:53 PM
    Thursday, September 3, 2009 12:50 PM

All replies

  • Hi jaydd

    I can try to repro your issue and see what is wrong.

    Do you have sample code you can share including where to place the breakpoint please?

    Cheers
    Daniel
    --
    http://www.danielmoth.com/Blog
    http://www.danielmoth.com/Blog/
    • Marked as answer by jaydd Thursday, September 3, 2009 12:53 PM
    Wednesday, September 2, 2009 5:44 PM
  • Hi Daniel,

    My bad; I had the breakpoint at the wrong place - here is my code out of context - after I placed a breakpoint at the "SaveDocument()" line - i could see the tasks in the tasks window ... the tasks didnt begin till the Aggregate forced the enumeration... Thanks

    var gamefilecounts = allGames.AsParallel().
                        Select(game => game.GameFiles.
                            Select(locator => GetXMLFromFileUri(locator)). 
                            Select(n => TransformXml(n)).
                            Aggregate(
                                0,
                                (int count, XElement n) =>
                                {
                                    //count each successive file as it is processed
                                    SaveDocument(n);
                                    return ++count;
                                }));

    int totalcount = gamefilecounts.Aggregate(0, (acc, indivcount) => acc += indivcount);

    jaydd
    • Marked as answer by jaydd Thursday, September 3, 2009 12:53 PM
    Thursday, September 3, 2009 12:50 PM