Click here to Skip to main content
15,352,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a fairly complicated console app in C#, and I have a list of values. I want to be able to run the app multiple times simultaneously. I want each running of the app to have a variable set to one of the values in the list, so as to see the effect of changing the value of that one variable has on how the program behaves.

What would be the most efficient way to implement this, so as to not drain resources on my laptop?

What I have tried:

I have made a console app with a main program, various methods, and several static variables.
Posted
Updated 29-Apr-22 10:39am

1 solution

Why?
The simpler solution would be to put each "instance of the application" into a separate thread within the actual app, with it reporting results back to the main thread. That way, resources are minimized (because all the threads will share the same process space instead of requiring independent heaps) and passing parameters to them can be as simple or complex as you need.

Start by looking at this: BackgroundWorker Class (System.ComponentModel) | Microsoft Docs[^] - it's simple to set up and simple to pass progress or other data back as necessary to the main thread for collation / display.
   
Comments
Admin BTA 29-Apr-22 19:30pm
   
I'll give it a whirl. Big thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900