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 7159055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:10:02+00:00 2026-05-28T13:10:02+00:00

foreach (int tranQuote in transactionIds) { CompassIntegration compass = new CompassIntegration(); Chatham.Business.Objects.Transaction tran =

  • 0
foreach (int tranQuote in transactionIds)
            {
                CompassIntegration compass = new CompassIntegration();
                Chatham.Business.Objects.Transaction tran = compass.GetTransaction(tranQuote);

                // then we want to send each trade through the PandaIntegration
                // class with either buildSchedule, fillRates, calcPayments or
                // a subset of the three
                PandaIntegrationOperationsWrapper wrapper = new PandaIntegrationOperationsWrapper { buildSchedule = false, calcPayments = true, fillRates = true };
                new PandaIntegration().RecalculateSchedule(tran, wrapper);

                // then we call to save the transaction through the BO
                compass.SaveTransaction(tran);
            }

Two lines here are taking a very long time. There’s about 18k records in transactionIds that I do this for.

The GetTransaction and SaveTransaction are the two lines that take the most time, but I’d honestly just like to thread out what happens inside the loop to improve performance.

What’s the best way to thread this out without running into any issues with the CPU or anything like that? I’m not really sure how many threads are safe or how to thread manage or stuff like that.

Thanks guys.

  • 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-28T13:10:03+00:00Added an answer on May 28, 2026 at 1:10 pm

    The TPL will provide the necessary throttling and managing.

    //foreach (int tranQuote in transactionIds) { ... }
    Parallel.ForEach(transactionIds, tranQuote => { ... } );
    

    It does require Fx4 or later, and all the code inside the loop has to be thread-safe.
    It’s not clear if your GetTransaction and SaveTransaction are safe to be called concurrently.

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

Sidebar

Related Questions

List<int> data=new List<int>(); foreach(int id in ids){ var myThread=new Thread(new ThreadStart(Work)); myThread.Start(id); } Work(){
int[][] myArray = new int[10][]; foreach (int[] eachArray in myArray) { eachArray = new
static void Main(string[] args) { List<int> listArray = new List<int>(); listArray.Add(100); foreach (int item
When i have a code block static void Main() { foreach (int i in
I have some code, int count = 0; list.ForEach(i => i.SomeFunction(count++)); This seems to
When foreach ing through a generic list I often want to do something different
I have this code: foreach(int i in Directions) { if (IsDowner(i)) { while (IsDowner(i))
I have a small thing. public int GetSum(List<int> x) { foreach (int i in
I have List of (PatchFacilityManager) and a List of (Int) facilityManagerId. I want to
Consider this List<int> intList = new List<int> { 1, 2, 3, 4, 5, 6

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.