cancel
Showing results for 
Search instead for 
Did you mean: 

Child window running in background..how to.

Former Member
0 Kudos

I have a child window that has a timer event which runs code that could take up to 3-5 seconds to run, timer kicks off every 2 minutes.

From a user perspective the app seems to stop for a bit (while the code in the timer event is running). Is there a way I can run this timer event in the background so that it does not effect the main app.

Dave V.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi David;

  You really need to tap into PB's multithreading features. Have a look at my example.

HTH

Regards ... Chris

Former Member
0 Kudos

Hi Chris...

Question.. how does the threaded object communicate or reference back to the main app?

Dave V.

Former Member
0 Kudos

Hi David;

  I gave a comprehensive session on this topic at the May PB Conference in Charlotte, NC this year. If you send me an email - I can send it to you for reference.  

FYI:  cpollach.at.travel-net.dot.com  (edit accordingly)  

regards ... Chris

Former Member
0 Kudos

email sent...

Answers (1)

Answers (1)

Former Member
0 Kudos

The SharedObjectRegister and related functions allow you to run functions within a non-visual object in a separate thread. The background thread has it's own set of global variables so will have to connect to the database before it does any SQL.

Here is an example. "shared_udp" is the thread name. Using Post tells it to run the function and don't wait for it to finish before going to the next line of code.

n_sharedobj ln_shr

If SharedObjectRegister("n_sharedobj", "shared_udp") = Success! Then

   If SharedObjectGet("shared_udp", ln_shr) = Success! Then

      ln_shr.Post of_BackgroundTask("something")

   End If

End If

Then to close the background thread:

SharedObjectUnRegister("shared_udp")

You can use a timer object within the background thread.

Former Member
0 Kudos

Strange things are at foot...

based on your sample above when the code for "SharedObjectRegister" runs I get

Application Terminated

Unresolved External message when linking...

what is weird is that the error is pointing to an object that is not part of the code that is running its' an instantiated object used elsewhere in the app.

SharedObjectRegister is somehow interacting with that object.

//////////////////////////

Follow up...

I removed the code in the offending event which was only comments and I am no longer getting the "app terminated" error but

still getting error of "sharedobjectcreatepbsession" error...

/////////////////////////////

Follow up 2

Finally got it to create.....

Question how can I pass a dw into it so that it can update data.  I created a function So I can set an instance variable on the object but I get an error about "object passed to shared/remote object method is not a nonvisual'

Thanks

Dave V.