Art,
Here is a simple example using a ProgressDialog:
/* Example using the ProgressDialog class */
.application~setDefaults('O', , .false)
.constDir['IDC_PB_FAKE1'] = 100
.constDir['IDC_PB_FAKE2'] = 101
.constDir['IDC_PB_FAKE3'] = 102
.constDir['IDC_PB_QUERY'] = 103
dlg = .SQLQueryDialog~new
dlg~execute("SHOWTOP", IDI_DLG_OOREXX)
::requires "ooDialog.cls"
::class 'SQLQueryDialog' subclass UserDialog
::method init
forward class (super) continue
self~create(30, 30, 257, 123, "Execute SQL Dialog", "CENTER")
::method defineDialog
self~createPushButton(IDC_PB_FAKE1, 10, 10, 50, 14, "", "Fake One")
self~createPushButton(IDC_PB_FAKE2, 70, 10, 50, 14, "", "Fake Two")
self~createPushButton(IDC_PB_FAKE3, 10, 35, 50, 14, "", "Fake Three")
self~createPushButton(IDC_PB_QUERY, 10, 60, 50, 14, "", "SQL Query",
execSQL)
self~createPushButton(IDOK, 142, 99, 50, 14, "DEFAULT", "Ok")
self~createPushButton(IDCANCEL, 197, 99, 50, 14, , "Cancel")
::method execSQL unguarded
self~start(longTask)
return 0
::method longTask unguarded
count = 1000
step = 10
pbDlg = .ProgressDialog~new
pbDlg~msgText = 'Executing an imaginary long-running task. This will
take some time.'
pbDlg~canCancel = .true
pbDlg~marqueeMode = .true
pbDlg~marqueePause = 50
a = .Alerter~new
pbDlg~setInterruptible(a)
self~disable
pbDlg~begin
pbDlg~updateStatus('0 loops executed')
do i = 1 to count
j = SysSleep(.1)
if i // step = 0 then do
pbDlg~updateStatus(i 'loops executed')
end
if a~isCanceled then do
pbDlg~updateStatus('canceled after' i 'loops executed')
r = SysSleep(1.5)
leave
end
end
pbDlg~endNow
self~enable
Some explanation:
I put a few 'fake' buttons in the main dialog just to simulate a more
complex dialog.
In longTask(), I disable the dialog before starting the task and then
re-enable it when the task is finished, or the user has canceled. This
prevents unwanted things happening.
When the user pushes the SQL Query button, I don't perform the task in the
event handler, instead I start a second thread that does the actual task
and return immediately from the event handler. You should take the same
approach in initDialog() so that initDialog() finishes up and returns.
Note that there is only an elegant solution for running a long task and
being able to cancel if the long task can be performed in steps. At each
step you need to be able to check if the user has canceled or not.
If you can not check at intervals, then one approach would be to start a
second thread running that periodically checks if the user has canceled,
and if so, kills the task. But, there may be no way to kill the task.
--
Mark Miesfeld
On Thu, Aug 15, 2013 at 7:15 AM, Art Heimsoth <artst...@artheimsoth.com>wrote:
> Thanks Staffan, I think solution 1. is what would work if I could get
> the dialog for it to display and the looping logic to also run.
>
> > 1. Dialog A starts Dialog B using popupAsChild passing a Cancel
> > object to it. The user can cancel the B process by pressing a
> > Cancel button in A. A changes the Cancel object accordingly, B sees
> > this by checking its status periodically, and terminates.
>
> I put the looping logic in B to look for the cancel signal in the
> initDialog method, but that prevents the B dialog panel from being
> displayed. How do I get that checking logic to run AND the dialog
> to be displayed?
>
> I assume that in order to keep the user from interacting with the other
> controls (other than the cancel button) in A, that I need to disable them
> while I have B displaying the "Wait" dialog, and then enable them again
> when B has been signalled to terminate. Is that correct?
>
>
> --
> Art Heimsoth - artst...@artheimsoth.com
>
>
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> _______________________________________________
> Oorexx-users mailing list
> Oorexx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-users
>
>
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users