Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6712931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:19:08+00:00 2026-05-26T08:19:08+00:00

I use linq to objects and I find out .ToList and .ToArray operation is

  • 0

I use linq to objects and I find out .ToList and .ToArray operation is blocking the thread. (In performance report, I see blocked time.) I guess it’s because GC is trying to allocate the memory when I call tolist or toarray. This is bad because I’m using linq in a parallel loop and I wish to access some shared collection in the linq.
Is there a way to solve this except not using linq to object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:19:09+00:00Added an answer on May 26, 2026 at 8:19 am

    Calling ToList or ToArray cause the query to get evaluated immediately – this will block the thread they are called on until the entire collection has been evaluated and the results of the query returned.

    You should iterate over the query directly without calling either method – this will stream the results in (assuming no other eager evaluation occurs).

    I suggest you take a look at the Task Parallel Library (TPL) if you need to do concurrent work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use LINQ to Objects instructions on an ordered array. Which operations shouldn't I
Can we use Business Objects which we made & data acess Layer of LINQ?
I'm trying to use LINQ To Objects to create a query that will give
I recently found LINQ and love it. I find lots of occasions where use
I find myself always needing to thin out objects before sending them over the
regarding linq to objects, if i use a .Where(x => x....) and then straight
How to use Linq to select and group complex child object from a parents
I use LINQ-SQL as my DAL, I then have a project called DB which
Assuming you can't use LINQ for whatever reason, is it a better practice to
I would like to use Linq to Xml to get a single XElement from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.