Re: Multi Threading Options
- From: "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>
- Date: Wed, 01 Jun 2005 07:32:16 -0500
Mark Randall wrote:
My problem is that I want to run a pretty hefty drawing routine on the other thread - I really want to cause thread 2 to wait for data to finish being written before it starts drawing the next image, and cause thread 2 to tell thread one it can update again once it has finished drawing.
In code such as this, where the threads are to "voluntarily" take turns, you have a third option. In addition to a mutex or crictical section, you can consider the use of an interthread message. When thread 1 finishes updating the list it can post a message to thread 2 requesting a paint. And vice versa. Use PostMessage to a GUI thread, PostThreadMessage to a non-GUI thread. Example here:
http://www.mvps.org/vcfaq/mfc/index.htm
-- Scott McPhillips [VC++ MVP]
.
- Follow-Ups:
- Re: Multi Threading Options
- From: Joseph M . Newcomer
- Re: Multi Threading Options
- References:
- Multi Threading Options
- From: Mark Randall
- Re: Multi Threading Options
- From: Joseph M . Newcomer
- Re: Multi Threading Options
- From: Mark Randall
- Multi Threading Options
- Prev by Date: Re: Very large CListView - How update view?
- Next by Date: Re: Accessing a document from classes that are included in a dialog
- Previous by thread: Re: Multi Threading Options
- Next by thread: Re: Multi Threading Options
- Index(es):
Loading