StrataFrame Forum

Asynchronous data loading

http://forum.strataframe.net/Topic11955.aspx

By Chan - 10/12/2007

Hi,

I created a BO which subclass BusinessLayer. I created FillAll() method which will load data from external source (not database). The data loading might take 30 seconds. The reason I put this code in BO is to ease data binding.



I would like to have async data loading for this. When form loaded, combobox should show "loading ..." as display value. Then program would call BO.FillAll() to query data from external source. Once complete, I want combobox to show "Please select a value" with a list of record.



How could I do this?



Thank you
By Trent L. Taylor - 10/12/2007

We have already implemented this in the 1.6.2 update.  There is now the ability to asynchronously retrieve a BLOB (VarBinary) field which raises events notifying you of the progress of the retrieval.  This was added so that large fields (i.e. VarBinary fields storing serialized or image data) could be retrieved without a timeout on the connection while displaying a progress bar to the end-user.

This will probably not be released for 30+ days as it needs to be finalized in testing.  But this logic has already been added to the BO.

By Chan - 10/12/2007

Hi,

What if my external data source is a very large XML, web service or large collection from other vendor class?



Does 1.6.2 allow me to do the same?
By StrataFrame Team - 10/15/2007

What Trent was describing allows you to retrieve a single column from the database that is a VarBinary(MAX) (or IMAGE) field.  It doesn't do anything for what you are describing.

What you will need to do is create a method somewhere that will create a background thread to load the data.  Basically:

1) Create the method to load combo box.

2) This method starts a new thread and passes over the parameters to get to the data source and the combo box that is being populated.

3) Thread then retrieves the data and set the DataSource, DisplayMember, and ValueMember properties on the combo box (using Invoke() on the combobox to prevent CrossThreadViolationExceptions).