File: n_demotask.sru
Size: 1326
Date: Mon, 31 Dec 2018 21:14:39 +0100
$PBExportHeader$n_demotask.sru
forward
global type n_demotask from n_sharedobject
end type
end forward

global type n_demotask from n_sharedobject
end type
global n_demotask n_demotask

forward prototypes
public subroutine of_mytask (integer ai_max)
end prototypes

public subroutine of_mytask (integer ai_max);// When using multi-threading, each background thread has its own
// set of global variables. This means that the background thread
// must connect to the database before doing any database work and
// disconnect from the database when done.

Integer li_idx

// The window displays this in a ListBox
of_SendMessage("Background task has started")

// Call a function in the window directly. Dynamic Function is needed
// because ipo_callback is the generic PowerObject datatype.
ipo_callback.Post Dynamic Function wf_msg("Example call of window function")

For li_idx = 1 To ai_max
   // Check to see if stop requested
   If of_StopRequested() Then
      Return
   End If

   // The window displays this in a ListBox
   of_SendProgress(li_idx, ai_max)

   // Pretend to be doing something
   Sleep(1)
Next

// Let window know the function is done
of_SendComplete()

end subroutine

on n_demotask.create
call super::create
end on

on n_demotask.destroy
call super::destroy
end on