Async Tasks

2
0

Hi everyone, im using a code to make things async, and it works perfectly.

Application.StartPolling(1000)
Application.StartTask(Function()
        ‘stuff here
 End Function)
Application.Update(Me)
Application.EndPolling()

However, only if I enforce an update on the page (Me.Update()) the async is terminated, or the async data is demonstrated, how can I do this?

I’m currently using a 1 second timer that does Me.Update(), but this is not the most efficient way, and it slows down the server. Does anyone have better ways to do this?

  • You must to post comments
0
0

Hi Ruben

Could you please explain what do you whant to achieve ?
Can you attach a runnable sample that show us how this affect?

regards

  • ruben ribeiro
    I just want to make a query to MySql, async so the website will not freeze, load or crash.
  • ruben ribeiro
    However this query will be executed every x seconds, and i need it to never crash you know. Is there any better way to do this? that does not consume so much resources from the computer?.
  • You must to post comments
0
0

Hi Ruben,

I don’t think you need to use polling unless you have websockets disabled.

this is the general process for retrieving data from a db and updating the UI:

 

Application.StartTask(() => {

    // perform some long-running db fetch.
    var data = GetDataFromDB();

    // apply changes to the ui.
    this.labelData.Text = data.Text;

    // push a websocket update to the client with the UI changes.
    Application.Update(this);
});

 

You can find more info here:

https://docs.wisej.com/docs/concepts/background-tasks#update-the-ui

 

HTH,

Levie

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.