Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Visual Studio .NET > Testing, Quality Control, Debugging

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-26-2009, 9:51 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jun 2009
Age: 30
Posts: 1
Reputation: 0
spidergirl1979 is on a distinguished programming path ahead
Question To thread or not to thread??

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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-27-2009, 7:04 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,325
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

Quote:
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.
Quote:
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.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
thread updating


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 7:20 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.