0

I'm having an issue with a program I'm working on... I have a listener for the webengines worker state, so that when state = SUCCEEDED it will carry on with the rest of the code.

The problem is that the website I'm loading has a lot of ads and takes a few minutes for the state to finally reach "SUCCEEDED".

I plan on using a timer, but the only way to trigger the listener is if the state changes, is there any way I could manually change the webengines worker state?

something like:

webEngine.getLoadWorker().getState() = Worker.State.SUCCEEDED;

This code obviously doesn't work, but you get the point.

4

1 回答 1

1
is there any way I could manually change the webengines worker state

No. The state represents the state of the worker thread that is loading the page. It only changes to SUCCEEDED when the web page has (successfully) completed loading.

If you don't need the page to be fully loaded in order to execute the code that you want to execute, then it doesn't make sense to use a listener on the worker state to trigger the code (or, at least, not one that waits for the SUCCEEDED state). To answer your question, you need to determine the logic behind when you want your code to be executed. If it's not needing to be executed when the page is completely loaded, when do you want it to be executed?

Or, to ask the same thing another way, perhaps: under what circumstances do you intend to change the state of the load worker to SUCCEEDED? Why not just execute whatever code you are intending to execute then instead?

于 2014-05-29T01:05:08.657 回答