jbizzy
jbizzy
CC#
Created by Umbranocturna on 9/17/2023 in #help
How to efficiently use Threads and locks
you'd need to decompose your calculation and render functions though
20 replies
CC#
Created by Umbranocturna on 9/17/2023 in #help
How to efficiently use Threads and locks
var parallelism = 8;//roughly equivalent to your threadcount
var pixels = Enumerable.Range(0,parallelism).AsParallel().Select(i=>(i,CalculatePixels(i*height/Parallelism))).ToList();
BitMap.Update(pixels);
var parallelism = 8;//roughly equivalent to your threadcount
var pixels = Enumerable.Range(0,parallelism).AsParallel().Select(i=>(i,CalculatePixels(i*height/Parallelism))).ToList();
BitMap.Update(pixels);
something kinda like that.
20 replies
CC#
Created by Umbranocturna on 9/17/2023 in #help
How to efficiently use Threads and locks
the setup you initially showed looks trivial to linqize
20 replies
CC#
Created by Umbranocturna on 9/17/2023 in #help
How to efficiently use Threads and locks
yeah. would keep you from needing to deal w/ all the manual thread manipulation
20 replies
CC#
Created by Umbranocturna on 9/17/2023 in #help
How to efficiently use Threads and locks
Then you just take the output of that and shove it in teh bitmap
20 replies
CC#
Created by Umbranocturna on 9/17/2023 in #help
How to efficiently use Threads and locks
Makes parallel computation very fast and easy, and automatically handles thread joining
20 replies
CC#
Created by Umbranocturna on 9/17/2023 in #help
How to efficiently use Threads and locks
You might try PLINQ
20 replies
CC#
Created by Umbranocturna on 9/17/2023 in #help
How to efficiently use Threads and locks
i would probably recommend using the task/async await model if you want to do something like that, rather than trying to manage raw threads yourself
20 replies