Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Multithreading and VB 2010: help!  (Read 2719 times)
asia
Customers
Community Member
*****
Posts: 182


« on: June 16, 2010, 04:58:38 AM »

Dear people,
I am writing an VB2010 application where to a landscape the texture chunks  closest to the player are replaced with high definition ones . The player is on a airplane moving on the landscape. Textures are taken from google earth. As the player moves  the view away the low resolution texture are set back. In this manner the texture memory is kept low.
High definition textures need time to load. Then, for the first time (yes I admit it), I really need a multithreading application. My approach is to insert a backgroundworker but I found a lot of troubles. Do you met this problem before? How did you managed it?
Any help will be appreciated
Logged

Fabio Musmeci
ENEA
CR Casaccia
Via Anguillarese 301
00060 Rome
Italy
musmeci@enea.it
+39 3333934898
Learning to live better on a smaller footprint..
Lenn
Customers
Community Member
*****
Posts: 876

+/-


« Reply #1 on: June 16, 2010, 11:43:38 AM »

It's not something you can explain in one post. But I will try. For example, I use a list of running threads and their IDs are the ones given by the managed .net app. That way I can call anything from a thread and it keeps track of which thread is calling it using that ID. I communicate between threads by using properties which synclock an object designated to "guard" one or more variables when they are set/get. I also keep track of non-threadable stuff using ManualResetEvent, so for example it is triggered when a thread needs the renderer so the rendering pauses in the main thread, then unhooks it when it's done. Also for example, i lock a collection of "finished threads" which is launched after the last line of a method in a thread is executed, i then add that thread to the collection, and then the main thread checks and updates if there are any threads in that collection that have been finished. I track the types of thread by their managed IDs and my own custom enumerations. That way i know what thread (and type of thread) has finished, and what to launch next. But what you are trying to do, loading textures, should be fairly simple. You just create a method that loads all of the textures, create a thread with its address, start it, and when the method finishes you set a variable that is constantly checked in the main loop that this thread is finished. Dont forget to have a variable of type Object to synclock while you are setting/getting that state variable.
Logged

TV3D 6.5 Community Docs - Read, use and please contribute!
asia
Customers
Community Member
*****
Posts: 182


« Reply #2 on: June 22, 2010, 02:43:00 AM »

OK I am getting older  Cry and I forgot to put TV.AllowMultithreading BEFORE the init method: 6 working days of struggling for not carefully check the debug file! Well, after all I have now some experience with the background worker. One day I will write a tutorial (maybe..)
Ciao
Logged

Fabio Musmeci
ENEA
CR Casaccia
Via Anguillarese 301
00060 Rome
Italy
musmeci@enea.it
+39 3333934898
Learning to live better on a smaller footprint..
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks