Guides/Windows Progress Dialog

From J Wiki
Jump to navigation Jump to search

Progress Dialog provides visual feedback for a long-running process. The script allows you to create a progress dialog, set its title, animation, text lines, progress. This dialog will update on a background thread, remain modeless, handle user cancellation of the operation, and estimate the time remaining until the operation completes. When minimized, it shows percent complete.


progress class is based on ole32 from Addons/general/pcall.

This is how the dialog is used during operations that require progress and the ability to cancel.

Wm yes check.png

Wm yes check.png

require 'general/pcall/progress'
T=: 1

p=: progress 'Testing Progress from J'

start__p ''
cancelmsg__p 'Cancelling'
1 line__p 'Progress reporting dialog'
delay__p 2*T

3 : 0 ''
for_t. 'Initializing ...';'Processed 1';'Processed 2';'Finished' do.
  if. c=. canceled__p '' do. break. end.
  10 progress__p t_index{0 2 8 10
  2 line__p ;t
  delay__p 2*T
smoutput c{::'Completed';'Canceled'

destroy__p ''