calling method of a webcontainer from thread

Hi,

I have a Webcontainer which has Weblistview control on it, and a REFRESH Method to get fetch the data from the database.

Since fetching record from database is tedious specially for large record count, I want to implement THREAD to show PROGRESS WHEEL in front.

My question is:

How can I call the REFRESH method resided at the Webcontainer within the THREAD.RUN (I want to show the progress wheel where fetching records) ?

Anybody who already implemented this scenario? Please share.

1 Like

Use a timer to refresh the progress bar. This is actually a very simple thing to do with the new framework. Have a method called ProgressBarUpdate or whatever you want to call it. Set it up like this:

Sub ProgressBarUpdate(value as Auto)
   Dim mValue as Integer = value
   ProgressBar1.value = value
End Sub

Now from your thread you execute this call whenever you want to update the progress bar:

dim mValue as Auto = SomeIntegerVariableOrProperty   

Xojo.Core.Timer.Calllater(0, AddressOf ProgressBarUpdate, mValue)

Now the timer will fire on the main thread and update your progress bar accordingly.

Thanks for the reply.

But I prefer Progresswheel in a modal dialog.

Can I still use your sample above?

Sure. But a progress wheel is always spinning and doesn’t need updates. So start the progress wheel when you start the thread. Then stop the progress wheel when the thread finishes.

Thanks Jon,

So how can I do that in code? Can you please provide me sample?

"I have a Webcontainer which has Weblistview control on it, and a REFRESH Method to get fetch the data from the database.

Since fetching record from database is tedious specially for large record count, I want to implement THREAD to show PROGRESS WHEEL in front."

So in your code BEFORE you start the thread (in fact put this the line before you call the run method of the thread) put:

ProgressWheel1.visible = True

When the thread finishes have a method that is called HideProgressWheel:

Sub HideProgressWheel
   ProgressWheel1.visible = False
End Sub

Now from the last line in the thread call:

Xojo.Core.Timer.CallLater(0, AddressOf HideProgressWheel)

There are no updates needed as the progress wheel is just a spinning thing.

Hi Jon,

My progresswheel is at the dialogbox (modal).

Does this mean that my code should be.

thread eventhandler-

dim dlg as dlgPleaseWait
dlg.show

run()


Is this correct?

Make sure your thread is a subclass of WebThread so it’ll be aware of the session it was started from.

Yes, as long as you have any UI calls before the thread, I think your code should work just fine.

Hi Guys,

I really really very thank full if you could provide me sample xojo project that works with tread+progress wheel+ webcontainer.

I cant make my experiment work.

Please???

Hi Guys,

Anybody can provide me sample on how to use PROGRESS WHEEL while loading data to Weblistbox?

Please.