forward
global type w_multithread from Window
end type
type st_5 from statictext within w_multithread
end type
type st_time from statictext within w_multithread
end type
type st_4 from statictext within w_multithread
end type
type st_3 from statictext within w_multithread
end type
type cb_1 from commandbutton within w_multithread
end type
type cb_2 from commandbutton within w_multithread
end type
type st_2 from statictext within w_multithread
end type
type st_1 from statictext within w_multithread
end type
end forward
global type w_multithread from Window
int X=247
int Y=224
int Width=1797
int Height=392
boolean TitleBar=true
string Title="Multi-Threading with PowerBuilder"
long BackColor=77652192
boolean ControlMenu=true
boolean MinBox=true
boolean MaxBox=true
boolean Resizable=true
event type long ue_thread1 ( )
event type long ue_thread2 ( )
st_5 st_5
st_time st_time
st_4 st_4
st_3 st_3
cb_1 cb_1
cb_2 cb_2
st_2 st_2
st_1 st_1
end type
global w_multithread w_multithread
type variables
nv_Test inv_Test1
nv_Test inv_Test2
nv_arg1 inv_arg1
nv_arg2 inv_arg2
on w_multithread.create
this.st_5=create st_5
this.st_time=create st_time
this.st_4=create st_4
this.st_3=create st_3
this.cb_1=create cb_1
this.cb_2=create cb_2
this.st_2=create st_2
this.st_1=create st_1
this.Control[]={this.st_5,&
this.st_time,&
this.st_4,&
this.st_3,&
this.cb_1,&
this.cb_2,&
this.st_2,&
this.st_1}
end on
on w_multithread.destroy
destroy(this.st_5)
destroy(this.st_time)
destroy(this.st_4)
destroy(this.st_3)
destroy(this.cb_1)
destroy(this.cb_2)
destroy(this.st_2)
destroy(this.st_1)
end on
type st_5 from statictext within w_multithread
int X=987
int Y=160
int Width=311
int Height=80
boolean Enabled=false
boolean Border=true
BorderStyle BorderStyle=StyleLowered!
string Text="00:00:00"
Alignment Alignment=Center!
boolean FocusRectangle=false
long TextColor=8388608
long BackColor=67108864
int TextSize=-8
int Weight=400
string FaceName="Arial"
FontCharSet FontCharSet=Ansi!
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type
type st_time from statictext within w_multithread
int X=987
int Y=48
int Width=302
int Height=76
boolean Enabled=false
boolean Border=true
BorderStyle BorderStyle=StyleRaised!
string Text="Time"
Alignment Alignment=Center!
boolean FocusRectangle=false
long TextColor=16711680
long BackColor=67108864
int TextSize=-8
int Weight=400
string FaceName="Arial"
FontCharSet FontCharSet=Ansi!
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type
type st_4 from statictext within w_multithread
int X=1317
int Y=48
int Width=384
int Height=76
boolean Enabled=false
boolean Border=true
BorderStyle BorderStyle=StyleRaised!
string Text="Count proces 2"
Alignment Alignment=Center!
boolean FocusRectangle=false
long TextColor=16711680
long BackColor=67108864
int TextSize=-8
int Weight=400
string FaceName="Arial"
FontCharSet FontCharSet=Ansi!
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type
type st_3 from statictext within w_multithread
int X=585
int Y=48
int Width=384
int Height=76
boolean Enabled=false
boolean Border=true
BorderStyle BorderStyle=StyleRaised!
string Text="Count proces 1"
Alignment Alignment=Center!
boolean FocusRectangle=false
long TextColor=16711680
long BackColor=67108864
int TextSize=-8
int Weight=400
string FaceName="Arial"
FontCharSet FontCharSet=Ansi!
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type
type cb_1 from commandbutton within w_multithread
int X=37
int Y=32
int Width=421
int Height=96
int TabOrder=20
string Text="SingleThreaded"
int TextSize=-8
int Weight=400
string FaceName="Arial"
FontCharSet FontCharSet=Ansi!
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type
event clicked;/* remove the thread object from memory */
type cb_2 from commandbutton within w_multithread
int X=37
int Y=160
int Width=421
int Height=96
int TabOrder=10
string Text="MultiThreaded"
int TextSize=-8
int Weight=400
string FaceName="Arial"
FontCharSet FontCharSet=Ansi!
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type
event clicked;if IsValid(inv_Test1) then
destroy inv_Test1
end if
if IsValid(inv_Test2) then
destroy inv_Test2
end if
/* you'll notice that the window events ue_thread1 and ue_thread2 are fired concurrently */
end event
type st_2 from statictext within w_multithread
int X=1317
int Y=160
int Width=384
int Height=80
boolean Enabled=false
boolean Border=true
BorderStyle BorderStyle=StyleLowered!
string Text="0"
Alignment Alignment=Center!
boolean FocusRectangle=false
long TextColor=8388608
long BackColor=67108864
int TextSize=-8
int Weight=400
string FaceName="Arial"
FontCharSet FontCharSet=Ansi!
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type
type st_1 from statictext within w_multithread
int X=585
int Y=160
int Width=384
int Height=80
boolean Enabled=false
boolean Border=true
BorderStyle BorderStyle=StyleLowered!
string Text="0"
Alignment Alignment=Center!
boolean FocusRectangle=false
long TextColor=8388608
long BackColor=67108864
int TextSize=-8
int Weight=400
string FaceName="Arial"
FontCharSet FontCharSet=Ansi!
FontFamily FontFamily=Swiss!
FontPitch FontPitch=Variable!
end type
forward
global type nv_test from nonvisualobject
end type
end forward
global type nv_test from nonvisualobject
end type
global nv_test nv_test
type variables
nonvisualobject inv_arg
long il_count
end variables
forward prototypes
public function integer of_start ()
public function long of_getcount ()
public function integer of_setparent (nonvisualobject anv_arg)
end prototypes
public function integer of_start ();time t1
t1 = now()
do while secondsafter(t1,now()) < 5
il_Count++
inv_arg.triggerevent('ue_thread')
loop
return 1
end function
public function long of_getcount ();return il_count
end function
public function integer of_setparent (nonvisualobject anv_arg);inv_arg = anv_arg
return 1
end function
on nv_test.create
TriggerEvent( this, "constructor" )
end on
on nv_test.destroy
TriggerEvent( this, "destructor" )
end on