I'm new to multi-threading so all the other issues aside for a moment. I'm having trouble working out how to resolve my sprite batch being ended by the faster thread and the next thread causing "Object reference not set to an instance of an object".
Oh and if you can see anything else wrong with my code feel free to make me feel like an idiot ^^
spriteBatch.Begin();
// Draw Particles
List<Thread> threads = new List<Thread>();
for (int i = 0; i < CPUCores; i++)
{
int tempi = i; // This fixes the issue with i being shared
Thread thread = new Thread(() => DrawParticles(tempi + 1, CPUCores));
threads.Add(thread);
thread.Start();
}
foreach (var thread in threads)
{
thread.Join();
}
// ..More Drawing Code..
spriteBatch.End(); // <-- This is where the program crashes
PS Who decided it was a good idea to use 4 spaces to signify code instead of [code] [/code]? ¬_¬