Multithreading:
Method 1: createthread
Needless to say, this is the only system method for creating threads in Win32.
Access this Win32 API, but the system is also created through it.
Method 2: timersetevent
This function is a high-precision timer function of the Win32 system. By calling this function, the system will create a new thread for Timer
The code in the callback function runs in this new thread.
Method 3: shcreatethread
Many people have never seen this function. This is an export function of shlwapi. dll. It can be understood literally as a multiline creation function.
And... He is a multi-threaded Function Based on Object operations, that is to say, he can stably run some of the above two methods to create
But cannot run stably. At least this function is quite satisfactory in the IDE environment! Use methods to query API-GUIDE
Method 4: Remember, createremotethread
The creation of a remote thread is not stable at all after testing. It is better to call createthread directly.
However, as a thread creation method, you still want to be familiar with it. If you do not need VB to write code, it is easy to write cross-process threads.
Otherwise, you can only continue set‑whook. If you are familiar with assembly instructions, you can also remotely allocate memory to write hard code for execution.
Method 5: ActiveX Multithreading
The Forum uses this method to implement stable multithreading. Although the code is good, I will not use it. Today, we advocate green software for a multi-line
And the registry must have more XX points, which is not good .. It is also troublesome to uninstall. Threads created using ActiveX and other methods are the heaviest
Where it is necessary, it is best to call any VB Function Based on the newly initialized object in the new thread. Do not call it across objects,
The ActiveX security thread itself uses this point. I don't know whether the old people studying ActiveX did not pay attention to it.
The current multithreading is a new thread for initialization, and the object initialized in this thread is the entire project. A huge waste of resources
It is not easy to control, not the effect you want. In a word, you must Initialize New objects on your own in the new thread and do not use instance inheritance.
Method 6: my thoughts
I remember that someone in csdn used a code to capture the machine code in the function through the function address. If you can know when the Code was imported into VB
The machine code is converted and the code is crawled and put into the array for execution. This should be very stable. This is purely an entertaining idea, although it can
Implementation, but it is a bit too much. Unless it is a hot player in VB multithreading, I don't think it should take too much effort to study this.
Method 7: asynchronous
Many people in the Forum asked how the code in the timer control event runs. In fact, this is asynchronous.
It is almost the same as Asynchronization. Most importantly, it is safe to implement code execution asynchronously in VB. In fact, when we start Windows GUI programming asynchronously
And then began to contact. For example, a message loop in a form is often executed asynchronously. When one message is being executed, another message
It may be a bit messy. The content of this post is all about. The next post contains me.
I forgot when to write the code. Taking that code as an example, I will introduce the application Asynchronization.
From: http://hi.baidu.com/qq980570691/blog/item/856dbcdfd3bc683e5882dd37.html