Quantcast
Channel: SCN : All Content - PowerBuilder Developer Center
Viewing all articles
Browse latest Browse all 2935

Thread callback to main thread

$
0
0

I've started experimenting with threads in PB.net.

I'm using this well known code to start up a thread with just populates an instance datastore with some rows.

 

// In main thread, fire up background thread which retrieves data

long ll_cnt

System.Threading.Thread l_thread

System.Threading.ThreadStart l_process


l_process = of_getDwData()

l_thread = create System.Threading.Thread(l_process)

l_thread.IsBackground = true

l_thread.Start()

 

And in the of_getDwData function:

 

// In function of_getDwData() which the thread is running

integer li_cnt

 

// Fill the instance datastore with data

for li_cnt = 1 to 10

          ids_left.InsertRow( 0 )

          ids_left.Object.rownumber[ li_cnt ] = li_cnt

next

 

// When this function is done i would like to go back to the main thread, using some kind of callback.

MainThread.of_threadIsDone()

 

And in the callback function, a DataWindow on the window can just copy the data fetched.

 

// In function of_threadIsDone that is runned on main thread.

// Copy the fetched data!

dw_1.object.data = ids_data.object.data

 

 

I've tried lots of stuff calling from the thread back to the main thread without success.

Could anyone please give me some pointers?



Viewing all articles
Browse latest Browse all 2935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>