ControlP5 Drop Down Freezes on Data load

I am building a Data Visualization that loads a fair amount of data from CSV files and builds a graph based on the data that is loaded. I am using a ControlP5 Drop Down list to select which data set to load. It takes a bit of time to load the data and I would like to use a "Loading..." screen to notify the user. So far I have noticed two things:

  • When the ControlP5 event triggers my data to load the drop down list gets stuck in the "down" or "open" position. I tried calling dropDown.close() but it didn't have any effect.
  • It seems like the draw loop is getting paused when the ControlP5 event is triggered preventing me from using this load screen

Any suggestions for ways around this?

I would like it to work like this: Open drop down list - select data - close drop down list - display load screen - load data - remove load screen

Answers

  • Answer ✓

    Use a thread to load the data, then it won't interfere with the main program / draw() loop. Use a boolean to know if the data is loaded.

  • @amnon That definitely fixed my problem and now the draw doesn't freeze during the data load. I am having an odd issue with the change from a "normal" method to a thread. I am now calling my data like this: thread("loadData"), it was loadData() before. The problem is when I select something from the drop down menu it loads the data that was selected the last time the drop down menu was used. It is always "one click behind". (I hope that makes sense) If I switch back to loadData() the problem goes away. Any ideas as to why this is happening? (I'm am a little unfamiliar with threads and I don't know if there is something I might be missing) Thanks for the help so far!

  • edited April 2014

    Use some println's to track the problem, which apparantly is the order in which things are happening. I think the problem is that the controlP5 field change may be happening somehow after the thread is called or something. Perhaps you can first let controlP5 trigger the new selection and also set a boolean to loadNewData = true and then call the loading thread from the subsequent draw loop. That way you are sure all preparations are finished before you start the loading thread.

  • @amnon It's got me stumped at the moment but I'll keep digging. Thanks for all of your help!

Sign In or Register to comment.