C s masters, especially MFC s masters, about AfxBeginThread

Updated on technology 2024-03-07
6 answers
  1. Anonymous users2024-02-06

    Generally, the first two parameters are used.

    afxbeginthread(unsigned int *(cdecl*)(void*),void*);

    The first parameter is a function pointer, which must return an unsigned int and a void pointer.

    The second parameter is the void pointer. In fact, the second argument is the argument passed into the function.

    Since the thread function must be a global function, the information to be used is basically passed through the void pointer.

    For example, create a new class.

    struct threadinfo

    Various parameters required.

    threadinfo* pinfo = new threadinfo;

    pinfo->*=*** assignment.

    afxbeginthread(threadfunc, pinfo);

  2. Anonymous users2024-02-05

    In this thread, you can't directly manipulate the UI with this.

    When you need to afxbeginthread, pass this pointer in.

    For example, if your class is classtest, there are two functions in it: a and b, where a is the thread function and b is the function that operates the ui.

    It needs to be like this. :afxbeginthread(a, this, 0, 0, 0, null);

    Then cast the argument in a.

    classtest* p = (classtest*)param;

    Then call p->b();

  3. Anonymous users2024-02-04

    classtest, which has two functions, a, b, a is a thread function, and b is a function that manipulates the ui.

  4. Anonymous users2024-02-03

    It can't be said to be a disadvantage, the total amount of CPU execution is fixed, and if you open multiple threads, it is equivalent to the CPU to be divided into several threads to execute. For a single CPU, only one thread can be executed at a time, and then he will switch to the next thread and execute again, which feels like it is happening at the same time because the switching speed is fast.

    If you have a lot of calculations to perform in your thread, you can consider optimization.

  5. Anonymous users2024-02-02

    The ones that start with AFX start with an impulsive modulo for the mfc can be thought of as class functions.

    Of course, you can use the API's createthread no problem;

    You can use closehandle to end the thread, and call it when you decide you want to end it.

  6. Anonymous users2024-02-01

    However, it is important to note that the first parameter of afxbeginthread should be declared as static.

Related questions
3 answers2024-03-07

Systematic review and learning, according to your own weaknesses to check and fill in the gaps! Most of the IELTS for Chinese students are lacking in listening and speaking, and you should also look at it according to your own English proficiency. Good training providers are Global and Practical IELTS, etc.

12 answers2024-03-07

Brain Strengthening** makes hair black.

Black sesame paste. >>>More

12 answers2024-03-07

Challenges can continue to recognize their own shortcomings, continuous improvement, this is very happy, the challenge fails, will continue to work hard, surpass yourself, this is very happy. >>>More

10 answers2024-03-07

The climatic characteristics of the temperate oceanic climate are: no severe cold in winter, no heat in summer, and relatively uniform precipitation throughout the year >>>More

23 answers2024-03-07

Don't get divorced, find a way to solve problems when you encounter them, instead of using divorce to escape. >>>More