How To use Yield() to persist the progress bar counter

I am sure as a PowerBuilder developer you have had requests to add a Progress Bar for a long running process. Also, the progress bar will definitely need to display which record is being processed at any point of time.

So naturally you will display a counter with some relevant information like maybe an invoice number or an employee id or similar unique key identifier that helps users to determine what record is being processed.

However, when you are running this process and the progress bar comes up and starts chugging along the counter, you may have noticed that if the application loses focus then the counter stops and you may see a ‘Not Responding’ message on the title bar. Here is how you can solve this annoying issue.

Code Snippet:

For i = 1 to dw_1.rowcount()

// Show Progress Bar

li_percent_index = (ll_company_row * 100) / ll_company_count

if isvalid(w_progressbar_common) then

w_progressbar_common.title = “Web Service”

w_progressbar_common.st_1. text  = “Processing ” + string(ll_company_row) + ” out of ” + string(ll_company_count) w_progressbar_common.uo_1.uf_set_position(li_percent_index)


end if


YIELD() — This call to the Yield function will keep your counter going steady even when you switch to any other application.



About pbgeeks 12 Articles
PBGeeks is a website for PowerBuilder Professionals to come together and explore the new features being released in PB. Participate in the Forum and exchange your thoughts with the other PB Gurus. Job seekers can find plenty of most recent jobs all around the world in the Jobs Listing section. Employers can post their job openings to be made available to the entire PB community.