|
-
Oct 21st, 2014, 09:02 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Dispose large number of controls quickly? or better manage resources?
I'm working on a sort of file browser, where I use a flow layout control to show images. Each time I switch to a new screen I need to clear the control, and load new images (pictureboxes). I had been calling FlowLayoutPanel.Controls.Clear(), however I recently discovered that doesn't properly release resources (specifically, window handles) which causes an "error creating window handle" exception after about 10,000 pictures being loaded (which adds up after a few refreshes of the control).
I tried a for each control loop to .dispose() each picturebox, but the loop takes much longer to process, and ends up making each control disappear individually, rather than as a group. Is there a way to dispose the entire control collection at once? or is there another option that I hadn't considered? (for example, a way to keep using controls.clear, and manage resources in the background?)
Any ideas are very appreciated.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|