| |

VerySource

 Forgot password?
 Register
Search
View: 873|Reply: 8

About using in threads :: PostMessage!

[Copy link]

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-4 11:00:01
| Show all posts |Read mode
I use in threads
:: PostMessage (g_HwndMain, WM_THREAD_END, 0,0);
Send a message to the main thread (main interface);
In the following order:
1) Open the thread and end the thread
2) Open the thread and end the thread
The third time the thread is opened, the program is wrong.
If the above statement is not available, you can open the thread and end the thread.
Please advise!
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 Invalid IP Address

Post time: 2020-5-17 10:15:01
| Show all posts
Post key codes for starting and ending threads, error phenomena and information
Reply

Use magic Report

0

Threads

57

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-5-23 00:30:01
| Show all posts
WaitForSingleObject?
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

Post time: 2020-5-25 20:00:01
| Show all posts
Use PosThreadtMessage in threads
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-26 08:45:01
| Show all posts
It should not be a problem of PostMessage. My program automatically sends PostMessage to the main thread every 200ms without error.
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-5-27 09:00:01
| Show all posts
This is a message during debugging, sorry, did not reply immediately!
The thread 0x6AC has exited with code 0 (0x0).
The thread 0x550 has exited with code 0 (0x0).
First-chance exception in SelfThread.exe (MFC42.DLL): 0xC0000005: Access Violation.
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-5-28 06:30:01
| Show all posts
I do n’t know how to use WaitForSingleObject, I ’m here
:: PostMessage (g_HwndMain, WM_THREAD_END, 0,0); add after
WaitForSingleObject (g_HwndMain, 1000);
Still wrong when debugging
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-5-28 20:15:02
| Show all posts
Open thread is
AfxBeginThread (ThreadCalTem, GetSafeHwnd ());
The off thread is a global BOOL type variable, so
bThreadStop = true;
In the loop calculation of the thread,
if (bThreadStop)
  break;

UINT ThreadCalTem (LPVOID pParam)
{
  do
  {
   if (bThreadStop)
    break;
   .....
  } while (.....)
  :: PostMessage (g_HwndMain, WM_THREAD_END, 0,0);
  return 0;
}
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-31 19:45:01
| Show all posts
Sometimes this is not necessary when the thread is closed. This can only be used in special circumstances.
m_bAuto ... I forgot my full name. The default is true, that is, the object is automatically deleted after the thread ends.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list