c# - create multiple threads and communicate with them -
i have program, takes long time initialize it's execution rather fast.
it's becoming bottleneck, want start multiple instances of program (like pool) having initialized, , idea pass needed arguments it's execution, saving initialization time.
the problem found howto start new processes passing arguments:
how pass parameters threadstart method in thread?
but start process , able communicate send each thread needed paramenters required it's execution.
the best aproach found create multiple threads initialize program , using communication mechanism (named pipes example it's running in same machine) able pass arguments , trigger execution of program (one of triggers break infinite loop, example).
i'm asking if can advice more optimal solution rather 1 came with.
i suggest don't mess direct thread
usage, , use tpl, this:
foreach (var data in your_initialization_logic_method_here) { task.run(() => yourdelegate(data), //other params here); }
more task.run
on msdn, stephen cleary blog
Comments
Post a Comment