Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Asynchronous Events Interuppting Main Thread

Featured Replies

This isn’t really a bug more of a question about how this could happen. 

For example - I have a script, at the start of the loop there’s a function that checks if the account is logged in. 

I have a login handler event that I execute in my onStart, in the constructor I setAsync(). In the  execute() method I return 5000; if the account is logged in, if not I log the account in without pausing the script executor (as the loop is checking the opposite condition).

9/10 this login handler runs without interupping the main thread. Occasionaly it runs, the account logs in but the onLoop running on the main thread stops. 

No errors in the log, nothing. Anyone ever experienced this before?

Edited by jca

Just to clarify:

  • You've built your own login event handler that is ran onStart
  • This event is set to asynchronous with a timeout of 5000ms
  • If you fail to login, the script should stop
  • If you successfully login, the script should proceed to the onLoop
  • The onLoop firstly checks to make sure you're logged in

 

If I've got this correct, then I don't think this is the right approach, because the onLoop will be called once onStart has been executed. You could block the onStart to delay the loop, but I would advise against it because onStart is only called once, and if there's a problem in its execution, the entire script would have to be restarted. Instead, I would handle all this within the loop; you can use a combination of boolean checks and timestamps to see where you are and where you should be:
 

onLoop

IF logged in

   DO stuff

ELSE IF we have entered in our login details

   IF we have clicked the login button

      IF 5 seconds have passed

         DO stop script

  ELSE

      DO click login

ELSE

   enter in login information

  • Author
1 hour ago, liverare said:

Just to clarify:

  • You've built your own login event handler that is ran onStart
  • This event is set to asynchronous with a timeout of 5000ms
  • If you fail to login, the script should stop
  • If you successfully login, the script should proceed to the onLoop
  • The onLoop firstly checks to make sure you're logged in

 

If I've got this correct, then I don't think this is the right approach, because the onLoop will be called once onStart has been executed. You could block the onStart to delay the loop, but I would advise against it because onStart is only called once, and if there's a problem in its execution, the entire script would have to be restarted. Instead, I would handle all this within the loop; you can use a combination of boolean checks and timestamps to see where you are and where you should be:
 

onLoop

IF logged in

   DO stuff

ELSE IF we have entered in our login details

   IF we have clicked the login button

      IF 5 seconds have passed

         DO stop script

  ELSE

      DO click login

ELSE

   enter in login information

Thanks for the reply... yeah the event is non blocking. The tricky part is I swap login details so the login event also listens to that. 

I actually switched to your approach to test it and it is flawless now. Good to have confirmation of my thinking though! 

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.