To thread or not to thread??

spidergirl1979

New member
Joined
Jun 26, 2009
Messages
3
Programming Experience
3-5
I'm programming a comic book design software that contains pages and comic panels (this is actually a custom control and will house things like the comic panel border, pictures, background colour etc...)

Basically when the user clicks on any comic panel, the toolbar will update accordingly. This works fine and well but I found say if the user clicks various panels rapidly that it seems to queue the requests to update the toolbar. I was thinking of possibly having the toolbar update function to be in a thread but when I tried that I got an error about it not being a safe thread call.

I'm not sure if I need to use a thread or how I can go about this. Basically if a user clicks on the first comic panel, it'll update the toolbar accordingly, but if the user clicks another comic panel before the toolbar is done updating, I want to cancel the previous call.

Currently the sub to update the toolbar is located in my custom comic panel control so each instance of the comic panel would have that same sub. Should I yoink it out and place it in my main form or can I leave it where it is?

I have limited knowledge in using threads but I understand the premise and that's why I was thinking of using a thread instead but I run into the problem of what happens when another panel runs a thread, the first panel can't access the first thread cause it's a local variable.

Oh, and I'm not using any databases or anything. The toolbar contains aspects of the panel itself like height, width, position etc...

Thanks for any help!
 
To thread or not to thread??
You should not do work that blocks the thread for any significant or undetermined time in UI thread, delegate that to a secondary thread.
I got an error about it not being a safe thread call
Deal with it, learn how to do multi-threading. Search term: "vb.net multi-threading" ;) The easiest start is to learn how to use the BackgroundWorker component in Toolbox.
 
Back
Top