Is There a Safety Limit to the Number of BOs on a Form?


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Sure.  It really depends on what I am trying to accomplish.  But let's take the scenario that you have a lot of BOs that must be loaded and there may be a number of child BOs that need to be loaded as well.  In this case, the easiest solution is to use the ThreadManager class and load each of the child BOs (and potentially the parents as well) on a thread.  For example, let's take the scenario below:

Tables with Respective BOs
Customers (Parent BO)
CustomerNotes (Child)
CustomerProducts (Child)
CustomerOrders (Child)

Now let's assume that I have the primary key of the parent (there are a lot of different scenarios that you can work this format into).  I am going to load the parent first, then load all of the children at the same time.

'-- Load the parent record
Customers.FillByPrimaryKey(customerPK)

OK, once the parent is loaded (and if you have the PK you may not really need to wait for the parent to load...but you get the idea) I want to spawn 3 threads to load all of the children at the same time.  The best way to do this is to create a method for each child BO to load:

Private Sub Fill_CustomerNotes()
    CustomerNotes.FillByParentPrimaryKey(Customers.cust_Pk)
End Sub

Private Sub Fill_CustomerProducts()
    CustomerProducts.FillByParentPrimaryKey(Customers.cust_Pk)
End Sub

Private Sub Fill_CustomerOrders()
    CustomerOrders.FillByParentPrimaryKey(Customers.cust_Pk)
End Sub

But I still need to call these on a thread.  Drop a ThreadManager on the form and name it something like, threadManagerChildrenRecords.  Once the parent BO has been loaded (or you are ready to load the children) start a process for each fill method:

threadManagerChildRecords.AddProcess(Addressof Fill_CustomerNotes, "Notes")
threadManagerChildRecords.AddProcess(Addressof Fill_CustomerProducts, "Products")
threadManagerChildRecords.AddProcess(Addressof Fill_CustomerOrders, "Orders")

Once each thread completes, the ThreadCompleted event will fire and you can test on the name of the thread specified in the AddProcess call.  In most cases, though, you can just handle the AllThreadsCompleted event of the thread manager to launch your post query logic (i.e. populate a list, grid, etc.).

This is a pretty basic overview, but it should at least give you some ideas.  We have taken this to another level in our medical software to even load the form (folders in our medical software) on a background thread and the once completed bring it to the main thread...this would require a much longer explanation.  But we use the logic explained above for the loading of child records in a number of occasions once the form has been loaded.  Hope that makes sense Smile

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Trent, I have a few forms that could probably benefit from some threading. Could you say a bit more about this, especially with regards to how this works with the FormLoad option for BOs, combos/lists, what objects do you load in background, etc. I sorta know about threading, but have much to learn in this area.



Thanks!
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yeah, I have some forms that have as many as 10+ ChildFormDialogs and 20+ BOs...however, I will start to thread things, etc. if the forms starts to feel, "sluggish." Smile  This is generally due to the number of objects being instantiated and then loading the BOs....so you can always mask the loading slowness by using threads.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Excellent!  That is good to hear.

Sounds like my form is a walk in the park compared to yours.  These things can get complicated quick, though.  All a user has to say is, "Do think we could add a ... ?"

No, wait...here's the real problem.  We say, "Sure."

Hehe

Robin J Giltner
Robin J Giltner
StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)
Group: Forum Members
Posts: 105, Visits: 650
We have a form with 26 Business objects, 11 sub classed BrowseDialogs, and a few other components with no problems.  Our form takes a second to load up in the application, but we haven't heard any complaints about form load times or anything so we haven't tried to change it to make it faster.

Hope this helps.

Robin Giltner

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I have a rather (in my opinion) complex form involving 14 business objects (so far).  Should I be considering some kind of safety limit to the number of business objects I am throwing on a form?  Also, I have three ChildFormDialogs on the same form...is there concern for those, as well?

Thanks,
Bill

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search