I've hit a bit of a speed bump in my program. I have an array here:
Dim objects(6400) As DBlock
I don't think I need to provide the DBlock code here - it basically inherits Panel. Also I can't (don't have access to it right now).
So what my problem is (if you want to call it that) accessing it from a thread executed by a BackgroundWorker. I understand I can't refer to the forms control collection because it result in an illegal cross-thread call. The forms name is GameScreen.
The code I'd like to be using is this:
For I As Integer = 0 To objects.Count - 1 Me.Controls.Add(objects(I)) Next
The issue is definitely not that my objects are not instantiated. I've made sure that they are.
The error occurs in line 2 of my snippet.
I'd like to know a way to still use a BackgroundWorker but not have it result in an illegal cross-thread call.
So if anyone has any documentation or pointers (0xC6BA!) I'd be extremely grateful.
Right now it takes 81 seconds to instantiate the blocks (that's pretty much what they are - this is a Minecraft style game) and add them within a Sub.
The reason for me wanting to use a BackgroundWorker is to split the workload a bit.
I won't even mention how long it takes to paint them all (at least not in this thread just yet ).
It is a rather large memory hog at least as far as my apps go (80K) and 50 CPU.
If you need any more info, I'd be happy to provide it. Thanks again!
EDIT: I'll try post the whole code tomorrow. I'm having multiple issues with it.
This post has been edited by DimitriV: 30 April 2012 - 12:23 AM