Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / July 2007

Tip: Looking for answers? Try searching our database.

Creating graphics in background

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mr peanut - 02 Jul 2007 22:48 GMT
My application requires user interaction with a graphics interface that is
changing (data is being collected and plotted). Sometimes the graphics
updates are slow and the user is locked out until completion for tasks like
scaling and reading the cursor and all that.

I would like to do all of the drawing and associated calculations in a
background worker then have the updated information flash onto the form
holding the graphics forthwith.

Is there a "Best" strategy for doing this??
mark.milley@binaryswitch.com - 03 Jul 2007 00:48 GMT
I don't have time for a full code sample, but here's a gentle nudge:

You're on the right track. Investigate the
System.ComponentModel.BackgroundWorker class (VB2005). The class runs
code on a seperate thread, while also presenting events that get
raised on the main WinForms thread. These events allow you to both
report progress and return a result when the second thread completes.

Along with the PercentComplete property, the ProgressChangedEventArgs
class has both a UserState (Object) property that you can use to pass
back the graphical data (bitmap, image, or some such) which represents
the current progress. This will allow you to hand back to the main
thread the current image you want displayed, while leaving the
application responsive.

Note: Make sure you set the WorkerReportsProgress property on the
BackgroundWorker to true.

Good Luck,

-Mark

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.