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

  • Home
  • SEARCH
  • 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 6379241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:06:44+00:00 2026-05-25T02:06:44+00:00

I have an extension method which takes in two list and compares them for

  • 0

I have an extension method which takes in two list and compares them for modifications then outputs a new list. Here is the code

public static List<Member> GetModifiedRecords(this List<Member> LocalMemberData, List<Member> RemoteMemberData)
    {
        var result = (from localdata in LocalMemberData
                      from remotedata in RemoteMemberData
                      where
                      ((
                      localdata.Card != remotedata.Card ||
                      localdata.DateJoined != remotedata.DateJoined ||
                      localdata.DatePaidUpTo != remotedata.DatePaidUpTo ||
                      localdata.Forename != remotedata.Forename ||
                      localdata.Postcode != remotedata.Postcode ||
                      localdata.State != remotedata.State ||
                      localdata.Street != remotedata.Street ||
                      localdata.Surname != remotedata.Surname ||
                      localdata.Title != remotedata.Title ||
                      localdata.Town != remotedata.Town
                      )
                      && (localdata.MemberNumber == remotedata.MemberNumber
                      ))
                      select localdata).Distinct();

        List<Member> modifiedMembers = new List<Member>(result);
        return modifiedMembers;
    } 

What’s strange is when running it fails on the line

List<Member> modifiedMembers = new List<Member>(result);

With the error

“The CLR has been unable to transition from COM context 0x3b4668 to COM context 0x3b44f8 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.”

FYI both Lists that are being compared have over 100,000 records. Am I thinking about this wrong?

  • 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-25T02:06:45+00:00Added an answer on May 25, 2026 at 2:06 am

    Consider a join, instead of filtering the cartesian product. For instance:

    var r = new Random();
    var list1 = Enumerable.Range(0,10000).OrderBy(_=>r.Next()).ToList();
    var list2 = Enumerable.Range(0,10000).OrderBy(_=>r.Next()).ToList();
    var sw = Stopwatch.StartNew();
    var c1 = from x1 in list1 from x2 in list2 where x1==x2 select x1;
    var j1 = c1.ToList();
    sw.ElapsedMilliseconds.Dump();
    sw=Stopwatch.StartNew();
    var c2 = from x1 in list1 join x2 in list2 on x1 equals x2 select x1;
    var j2 = c2.ToList();
    sw.ElapsedMilliseconds.Dump();
    

    Gives timings of

    3584
    1
    

    i.e. joins are super fast (complexity O(n)), your pseudo-join isn’t (complexity O(n2)).

    At 100000 items, my machine choked (I quit after 5 minutes) on the cartesian product filtering approach, but completed the join in 21ms.

    So, rewriting your query as follows should really turbo things up:

    (from localdata in LocalMemberData
    join remotedata in RemoteMemberData 
    on localdata.MemberNumber equals remotedata.MemberNumber
    where
    (
    localdata.Card != remotedata.Card ||
    localdata.DateJoined != remotedata.DateJoined ||
    localdata.DatePaidUpTo != remotedata.DatePaidUpTo ||
    localdata.Forename != remotedata.Forename ||
    localdata.Postcode != remotedata.Postcode ||
    localdata.State != remotedata.State ||
    localdata.Street != remotedata.Street ||
    localdata.Surname != remotedata.Surname ||
    localdata.Title != remotedata.Title ||
    localdata.Town != remotedata.Town
    )
    select localdata).Distinct()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an extension method which I can use from the .cs codebehind of
I currently have an extension Method which converts an IEnumerable of type Tab into
I have created a Generic Extension method for DataRow object. The method takes no
i have an extension method which a person was really helpful to give me...
Say I have a method called GetCatsByColor which takes a color as a string,
I have a really simple extension method which is constrained for IComparable instances: public
I have written an extension method which finds a control depending on the Type
I have an extension method on the HttpApplicationState object for getting my IoC container
What is necessary to have an extension method honored when it exists in an
I have a simple extension method on the int type so I can do

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.