Using "Wait-for" from within a class

Can I use a "wait-for" in a class file or is it a bad practice or bad conceptualization?

What I am trying to achieve is design a class for a "Progress meter" (or a thermometer) which shows the progress of records being processed in a report or utility.

I would like to encapsulate the whole thing in a class. While the progress meter is running I would like to enable a 'Cancel' button which will abort the process.

I am able to achieve the above idea without a 'cancel' button. But if I have to implement a 'cancel' button I need to use 'WAIT-for' right? Where / how can I implement this 'WAIT-FOR' within the class file?

So how do I accomplish this?

I have given the class file below.

Please let me know your thoughts / suggestions.

Thanks
Joel




CLASS mast.ProgMeter:


DEFINE private VARIABLE FractionOfBar AS DECIMAL NO-UNDO.
DEFINE private VARIABLE AccumFractionOfBar AS DECIMAL NO-UNDO.
DEFINE private VARIABLE OrigWidthPixels AS DECIMAL NO-UNDO.


DEFINE private variable ErrorCode as integer no-undo.
DEFINE private variable ErrorString as character no-undo.


DEFINE private BUTTON Btn_Cancel AUTO-END-KEY
LABEL "Cancel"
SIZE 15 BY 1
BGCOLOR 8 .


DEFINE PRIVATE VARIABLE fc-thermometer AS CHARACTER FORMAT "X(256)":U
VIEW-AS TEXT
SIZE 77 BY 1
BGCOLOR 1 NO-UNDO.


DEFINE PRIVATE RECTANGLE RECT-2
EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
SIZE 77 BY 1.1.


DEFINE PRIVATE FRAME Dialog-Frame
fc-thermometer AT ROW 1.57 COL 2 NO-LABEL WIDGET-ID 8
RECT-2 AT ROW 1.52 COL 2 WIDGET-ID 14
SPACE(0.79) SKIP(0.61)
WITH VIEW-AS DIALOG-BOX KEEP-TAB-ORDER
SIDE-LABELS NO-UNDERLINE THREE-D SCROLLABLE
TITLE "Progress Meter" WIDGET-ID 100.


CONSTRUCTOR public ProgMeter(TotalCount as decimal):
AccumFractionOfBar = 0.
OrigWidthPixels = fc-thermometer:WIDTH-PIXELS IN FRAME Dialog-Frame.
FractionOfBar = fc-thermometer:WIDTH-PIXELS IN FRAME Dialog-Frame / TotalCount.
fc-thermometer:width-pixels in frame Dialog-Frame = 1.

view frame Dialog-Frame.


END METHOD.


METHOD public logical SetMeterTitle(MeterTitle as character):
frame Dialog-Frame:title = MeterTitle.


return true.
END METHOD.


METHOD public logical IncrementMeter():
AccumFractionOfBar = AccumFractionOfBar + FractionOfBar.


if AccumFractionOfBar > OrigWidthPixels then
fc-thermometer:WIDTH-PIXELS IN FRAME Dialog-Frame = OrigWidthPixels.
else do:
if AccumFractionOfBar >= .5 then /* minimum width-pixels must be .5 */
fc-thermometer:width-pixels in frame Dialog-Frame = AccumFractionOfBar.
end.


return true.
END METHOD.


METHOD public integer ErrorCode():
return ErrorCode.
END METHOD.


METHOD public character ErrorString():
return ErrorString.
END METHOD.


DESTRUCTOR PUBLIC ProgMeter():


END METHOD.
END CLASS.
 
I used the following stub to test my class and it works fine.


DEFINE VAR met AS CLASS mast.progmeter NO-UNDO.
DEFINE VARIABLE ii AS INTEGER NO-UNDO.
DEFINE VARIABLE jj AS INTEGER NO-UNDO.


met = NEW mast.progmeter(1000).


met:SetMeterTitle('tester').


DO ii = 1 TO 1000 :
met:IncrementMeter().
DO jj = 1 TO 10000:
END.
.
END.

DELETE OBJECT met.
 
Top