CodePudding user response:
http://blog.csdn.net/gaoqiangz/article/details/39613559This article can have a look
CodePudding user response:
PB has several functions that are used multithreadingSharedObjectRegister ()
SharedObjectGet ()
SharedObjectUnregister ()
Using SharedObjectRegister (Classname, Instancename) PB help file is Classname and Instancename, namely the name of the class and instance name,
Using SharedObjectGet (instancename, objectinstance) to bind the instance name and the specific object instance, then you can POST through object instance set predefined procedure or function in the class, such as predefined uo_add function in the class, can objectinstance. POST uo_add
With SharedObjectUnregister (instancename) Unregisters a user object that was previously registered. Off user instance objects
Eg.
1, define a nvo_multithread
Add the add (int ai_n) function
Int li_i
Int li_result=0
Sleep (5)
For li_i=0 To ai_n
Li_result +=li_i
Next
Messagebox (" ", string (li_result))
2, define a window, in the Instance Variables defined Variables: nvo_multithread invo_thread
3, in the Open event code:
Invo_thread=Create nvo_multithread
Thread1 nvo_multithread SharedObjectRegister (" ", "")
SharedObjectGet (" thread1 invo_thread)
4, in the Close event code:
Destroy invo_thread
Thread1 SharedObjectUnregister (" ")
5, can call in a button Click event:
Int I
Invo_thread. Post to the add (I)
After the call, can be executed asynchronously
Note: if you want multiple threads to perform together, it must register several more instance objects, which perform a few times more step 2, 4, can use an array to do,
For example, I in the Instance Variables defined as nvo_multithread invo_thead [5]
Open event: the For li_ii=1 to 5
Invo_th [li_ii]=Create nvo_multithread
SharedObjectRegister (" nvo_multithread tthread ", "" + string (li_ii))
SharedObjectGet (" tthread "+ string (li_ii), invo_th [li_ii])
Next
Close events: the For li_ii=1 to 5
Destroy invo_th [li_ii]
SharedObjectUnregister (" thread "+ string (li_ii))
Next
CodePudding user response:
Refer to the link: http://blog.csdn.net/namgking/article/details/3421359