Click here to Skip to main content
15,886,919 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionhi Pin
keanue1-Feb-09 11:35
keanue1-Feb-09 11:35 
AnswerRe: hi Pin
Andy_L_J1-Feb-09 12:57
Andy_L_J1-Feb-09 12:57 
AnswerRe: hi Pin
Colin Angus Mackay1-Feb-09 12:57
Colin Angus Mackay1-Feb-09 12:57 
AnswerRe: hi Pin
N a v a n e e t h1-Feb-09 13:29
N a v a n e e t h1-Feb-09 13:29 
QuestionUI multithreading question Pin
Florin Iulian Anton1-Feb-09 11:33
Florin Iulian Anton1-Feb-09 11:33 
AnswerRe: UI multithreading question Pin
Guffa1-Feb-09 13:14
Guffa1-Feb-09 13:14 
AnswerRe: UI multithreading question Pin
Dave Kreskowiak1-Feb-09 17:48
mveDave Kreskowiak1-Feb-09 17:48 
AnswerRe: UI multithreading question Pin
supercat92-Feb-09 7:05
supercat92-Feb-09 7:05 
All code that draws to the UI in a particular window must be in a single thread. Even MDI child windows must be drawn by the same thread as the parent (a restriction I would think wouldn't be necessary if the system were could force thread synchronization when, and only when, a child window changes dimension). If you want to create the appearance of having things done by different threads, you need to have a UI thread that avoids doing anything that will take much time, and then have other threads supply information to the UI thread. As an example (not the best approach, but a workable one) you could allocate three bitmaps for one of your tabs. At any given moment, one may be in use by the UI thread (copying data from it to the screen), one may be 'ready' for the UI thread to grab at its convenience, and one will be in use by the helper thread to draw the next screen. When the helper thread finishes drawing a bitmap, it tells the UI thread to display it (using BeginInvoke if there isn't already a request pending). If there was a bitmap pending for display but the UI thread hasn't started showing it yet, the helper thread can take it back (since the UI should show the newer bitmap). Otherwise the helper thread can reclaim the previous bitmap the UI thread displayed (since the UI thread is done with it).

I'm not sure of the best way to handle the thread synchronization, but an easy way would be to recognize that there are twelve possible bitmap states (the drawing tread can hold any of three bitmaps and the UI thread one of the remaining two, and the remaining bitmap may or may not have data that should be displayed). The state can easily be held in an integer, and Threading.Interlocked.CompareExchange used to handle state updates in thread-safe fashion.

This approach would not be the best for fast and frequent display updates (since the whole tab would have to be redrawn for every update) but it would be a simple way to provide essentially total separation of the two threads.
QuestionZed Graph problem Pin
TheComputerMan1-Feb-09 5:05
TheComputerMan1-Feb-09 5:05 
Questionschool admission algorithm Pin
Gideon W. Wananda31-Jan-09 22:37
Gideon W. Wananda31-Jan-09 22:37 
AnswerRe: school admission algorithm Pin
Christian Graus31-Jan-09 22:55
protectorChristian Graus31-Jan-09 22:55 
GeneralRe: school admission algorithm Pin
Gideon W. Wananda31-Jan-09 23:12
Gideon W. Wananda31-Jan-09 23:12 
GeneralRe: school admission algorithm Pin
Eddy Vluggen31-Jan-09 23:24
professionalEddy Vluggen31-Jan-09 23:24 
QuestionHow to search In a Structure ? Pin
Georg Kohler31-Jan-09 18:51
Georg Kohler31-Jan-09 18:51 
AnswerRe: How to search In a Structure ? Pin
Christian Graus31-Jan-09 22:11
protectorChristian Graus31-Jan-09 22:11 
GeneralRe: How to search In a Structure ? Pin
Georg Kohler1-Feb-09 15:10
Georg Kohler1-Feb-09 15:10 
GeneralRe: How to search In a Structure ? Pin
Christian Graus1-Feb-09 21:15
protectorChristian Graus1-Feb-09 21:15 
AnswerRe: How to search In a Structure ? Pin
Guffa2-Feb-09 1:22
Guffa2-Feb-09 1:22 
QuestionScreen undraws everything when trying to capture Program Manager Pin
o m n i31-Jan-09 17:28
o m n i31-Jan-09 17:28 
AnswerRe: Screen undraws everything when trying to capture Program Manager Pin
Colin Angus Mackay31-Jan-09 17:41
Colin Angus Mackay31-Jan-09 17:41 
GeneralRe: Screen undraws everything when trying to capture Program Manager Pin
o m n i31-Jan-09 17:51
o m n i31-Jan-09 17:51 
QuestionMS Access, MS Word, custom app Pin
syba31-Jan-09 15:14
syba31-Jan-09 15:14 
AnswerRe: MS Access, MS Word, custom app Pin
Dave Kreskowiak31-Jan-09 16:26
mveDave Kreskowiak31-Jan-09 16:26 
AnswerRe: MS Access, MS Word, custom app Pin
Eddy Vluggen1-Feb-09 0:18
professionalEddy Vluggen1-Feb-09 0:18 
QuestionAdd transparent border around image to make it larger Pin
o m n i31-Jan-09 15:00
o m n i31-Jan-09 15:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.