Home > Software engineering >  GDI multithreading
GDI multithreading

Time:10-09

The function of two threads, each thread is respectively in the main interface drawing
 HDC hdc1=GetDC () - & gt; M_hDC; 
GraphSin=: : new Graphics (hdc1);
GraphAdvice=: : new Graphics (hdc1);

Thread1 {
DisplaySinCurve (GraphSin);
}

Thread2 {
DisplayAdvice (GraphSin);
}

DisplaySinCurve (Graphics * WorkGraphics) {
Bitmap * CompatibleBitmap=: : new Bitmap (500, 250);
Graphics * CompatibleGraphic=: : new Graphics (CompatibleBitmap);
//drawing operations
//double buffer
the corresponding to the main interfaceWorkGraphics - & gt; DrawImage (CompatibleBitmap m_destStatic_Advice,
0, 0, CompatibleBitmap - & gt; GetWidth (), CompatibleBitmap - & gt; GetHeight (), UnitPixel);
}

DisplayAdvice (Graphics * WorkGraphics) {
Bitmap * CompatibleBitmap=: : new Bitmap (500, 250);
Graphics * CompatibleGraphic=: : new Graphics (CompatibleBitmap);
//drawing operations
//double buffer
the corresponding to the main interfaceWorkGraphics - & gt; DrawImage (CompatibleBitmap m_destStaticRect_Sin, 0, 0, CompatibleBitmap - & gt; GetWidth (), CompatibleBitmap - & gt; GetHeight (), UnitPixel);
}

Problem is to run one thread drawing have no problem, after the operation, both appeared in front of things painted brush problem (double), you can't get rid of Daniel, please solve,

CodePudding user response:

Was supposed to be four curve, translation, as long as the draw another thread, the curve will appear eight or more,

CodePudding user response:

Advice only draw in one thread, easy to control the

Ontouch ()
{
If (fb) {}
//fill backgroundIf (f1) {draw1 (); }
If (f2) {draw2 (); }
{if (fn) drawn (); }
}

CodePudding user response:

Single thread can also, I want to know why this error, comparison,
Single thread if several drawing function execution speed will slow down together

CodePudding user response:

refer to the second floor zgl7903 response:
advice only draw in one thread, easy to control the

Ontouch ()
{
If (fb) {}
//fill backgroundIf (f1) {draw1 (); }
If (f2) {draw2 (); }
{if (fn) drawn (); }
}
single thread can also, I want to know why this error, comparison,
Single thread if several drawing function execution speed will slow down together

CodePudding user response:

Multiple Threads in the User Interface of http://msdn.microsoft.com/zh-cn/library/ms810439.aspx

CodePudding user response:

His own roof, a great god not to respond?

CodePudding user response:

The individual feels two threads should operate the same cache (Bitmap * CompatibleBitmap) joint, instead of two pieces of cache,
Ghosting reasons may be as two pieces of cache forward at the same time the same devices respectively carry out the DrawImage ()
Above is only a guess, is the underlying such execution

CodePudding user response:

You each thread drawing will focus on together, that certainly will appear such circumstance.
The right thing to do, is to time-consuming drawn into the thread, and draw to buffer, then from the UI thread drawing them all to the screen.
Rather than each thread in DC to draw direct operation equipment.

CodePudding user response:

refer to the eighth floor xiaohuh421 response:
you each thread drawing will focus on together, it will appear such circumstance.
The right thing to do, is to time-consuming drawn into the thread, and draw to buffer, then from the UI thread drawing them all to the screen.
Rather than each thread on operating equipment DC to draw directly.

up

CodePudding user response:

refer to 6th floor u011250543 response:
his top, no great god can reply?

Great god answered 5 floor,

CodePudding user response:

references to the tenth floor zhao4zhong1 response:
Quote: refer to the sixth floor u011250543 response:

His own roof, a great god not to respond?

Great god answered 5 floor,

Naughty zhao four teachers
  • Related