Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi Team,

How to create Concurrent Program or Parallel Programming in C# in windows application with specified time

For Example:

I want to split my big functionalities more than N small functions.
[N = 1, 2, 3,...., 1000]

These functions side by side running and execute the result,
I need to execute very fast these result. by using Threading

For Example:
Normal Function execution Time : 10Sec or more
Using Threading Execution Time : I need Only less than 1 sec or less

How to possible to create threading and solve my Issues,
Please help

and Thanks in Advance.
Posted
Updated 18-Mar-14 4:59am
v2
Comments
Krunal Rohit 18-Mar-14 11:00am    
Did you care to put any efforts so far ??

-KR

 
Share this answer
 
Well, you're going to have to design your code to be as efficient as possible. There are any unmber of ways this can be done. Which one is appropriate is going to take a bunch of research and testing on YOUR PART. to figure this out.

We have no idea what you know about threading in C# nor anything about your requirements so it's impossible to tell you which way to go. At best,m you'll get suggestions, but nothing is going to save you from a bunch of research and testing work.

Keep in mind, that no matter what method you chose, throwing piles and piles of threads at a computational problem does NOT get you more and more performance. A CPU can only run so many threads at one time, and it's usually limited to 8 or less right now on a Hyperthreaded Quad-Core CPU.
 
Share this answer
 
You can't execute 1000 functions in true parallel: not unless your PC has 1000+ cores, as you need a core to process each thread. However, you can get up to the number of cores you have running truly in parallel as separate threads, either by using Threading manually, or via Parallel.For[^]

However, be aware that creating and starting threads takes time, so 1000 small jobs set up as individual threads may well take more real time to execute than the same 1000 small jobs done consecutively!
 
Share this answer
 

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