I'm currently working on a process that receives "real-time" information using sockets. These information are displayed within a spark datagrid.
The informations received can have several formats such as :
* Add this line to the grid,
* Update this line of the grid
* Remove this line of the gris.
But the problem is as the data are arriving continuously, the datagrid can't refresh, and the application frezees. So I wonder how I could put the datagrid inside a worker, in order to have a smooth application while receiving data.
Thanks a lot for your help.
I completely agree with you, but the answer to this of the collegues for who I am developping the application says : "Maybe, but it works with the old VB6 version, so it should work with your new version"
Maybe you can filter the changes ( are there duplicates in the data )?
Another strategy is to batch the changes. Make a change no more often than say once every second or couple of seconds, or.. If you have a queue of 100 changes, do them all together.
What I am trying to do is to read data in a separate worker, and then get the received messages every second, but even if I use registerClassAlias, I am losing the types of the objects sent (I use getSharedProperty).
How can I make sure to keep the type of the object ?
I managed to cast it by adding [RemoteClass(alias="package.className")] in the object I use. So I can now receiv my data and buffer it in a worker. But the application still freezes when 600 lines are present, and when I make several removes.
Your case is rather unusual, to say the least, and bordering on the absurd.
You have 600 lines present, but they change multiple times every second. It sounds a bit like watching the windows process manager.
You can't read 600 lines at once and you can't scroll reliably either because the underlying data that you are seeing is changing all the time.
Probably what I might do is only have a grid that is as large as can fit on your page. Make the underlying data source only have as many rows as can be seen. Ditch the scrollbars for your grid.
Have a separate scrollbar to page content, or use tabs.
Maintain your incoming data manipulations in an Array or Vector. If you have 50 lines in your datagrid, copy 50 entries into a seperate array and use that as the datasource for the datagrid. Change the data in the datasource array according to updates received or paging via the scrollbar/tabs.
This should greatly reduce the load on the datagrid and screen refresh.
Before incorporating it into your app, build a test app and test the performance.
I've implemented this solution into my app, and it runs correctly now for this special overload case, so it will also work for a normal flow of information. Great thanks for your help pauland
But using this solution, I'm facing a new problem, each time I refresh the screen (every 1 sec), I lose the selected lines. Do you have an idea how i could "restore" the selection after a refresh ?
Big thanks again for your help !
Since the selected lines will change as the content changes, you'll need to remember the key for any selected line, before refreshing. By key, I mean a unique identifier, other than the position in the array.
Remember the selected keys, refresh the display, search for selected keys and select the row again.