打印本文 打印本文 关闭窗口 关闭窗口
VB创建多线程应用程序(二)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2194  更新时间:2009/4/23 16:37:42  文章录入:mintao  责任编辑:mintao

源代码如下:

窗体中的代码:

Option Explicit

 

''''开始

Private Sub Command1_Click()

  

   On Error Resume Next

  

   With myThreadleft

        .Initialize AddressOf Fillleft            ''''传递过程地址给线程

        .ThreadEnabled = True

   End With

   With myThreadright

        .Initialize AddressOf Fillright

        .ThreadEnabled = True

   End With

   With myThreadbottom

        .Initialize AddressOf Fillbottom

        .ThreadEnabled = True

   End With

  

   MsgBox "多线程正在运行...,看看图片框控件的变色效果!", 64, "信息"

  

   ''''终止线程运行

   Set myThreadleft = Nothing

   Set myThreadright = Nothing

   Set myThreadbottom = Nothing

  

End Sub

 

''''结束

Private Sub Command2_Click()

   Unload Me

End Sub

模块中的代码:

Option Explicit

 

''''时间计数API

Private Declare Function GetTickCount Lib "kernel32" () As Long

 

''''声明cls_thread类的对象变量

Public myThreadleft As New cls_thread, myThreadright As New cls_thread, myThreadbottom As New cls_thread

  

Sub Main()

   Load Form1

[1] [2] [3] [4] [5]  下一页

打印本文 打印本文 关闭窗口 关闭窗口