Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
Par2: How to start threads automatically at startup?
2006-02-13 -- Lee White
>I want to start several procedures automatically when my app/frame is
>loaded.
>My C55 code was quite simple:
>GloThread_A = START(Proc_A,25000)
>GloThread_B = START(Proc_B,25000)
>GloThread_C = START(Proc_C,25000)
>Doing this in C6.3 (9050) freezes my program.
I would suggest using Notify() & Notification() to work through your
stack of procedures. This is the method I've use in AFE since the
introduction of real threads and running into the same problem you
did. AFE starts 12 threads when it first loads!
MainThread LONG
NotifyCode UNSIGNED
NotifyThread SIGNED
NotifyParam LONG
OPEN(AppFrame)
ACCEPT
CASE EVENT()
OF EVENT:OpenWindow
MainThread = THREAD()
NOTIFY( 1, MainThread, 1 )
OF EVENT:Notify
IF NOTIFICATION(NotifyCode,NotifyThread,NotifyParam)
IF NotifyCode = 1
EXECUTE NotifyParam
tDrawCover = START(Draw_CoverSheet,50000)
tDrawPages = START(Draw_FaxPages,50000)
tAppendTIF = START(AppendTIF,50000)
tRefreshSystem = START(RefreshSystem,30000)
tBuildQueue = START(BuildQueue,20000)
tScheduleFax = START(ScheduleFax,20000)
tCompletedFax = START(CompletedFax,20000)
tFailedFax = START(FailedFax,20000)
tFailedSchedule = START(FailedSchedule,20000)
tPrintReport = START(PrintReport,20000)
tHandleXref = START(HandleXref,20000)
tFaxCore = START(FaxCore,40000)
END
END
END
! example of procedure...
Draw_CoverSheet PROCEDURE
CODE
ACCEPT
CASE EVENT()
OF EVENT:OpenWindow
NOTIFY( 1, MainThread, 2 )
! example of procedure...
FaxCore PROCEDURE
CODE
ACCEPT
CASE EVENT()
OF EVENT:OpenWindow
NOTIFY( 1, MainThread, 13 )
Today is November 21, 2024, 7:38 am
This article has been viewed 35227 times.