Jump to content

Delay DataCheck


meikelenboom

Recommended Posts

 

void PluginDataCheck()

This is where your plugin checks whether it needs to inform you about something, perfect place for notifications to be sent. It gets called automatically every 15-20 seconds.

 

 

I'm looking for a way to delay this check. I'm running queries and I don't want to burden my server too much. Does anybody have a best practice to decrease to, for example every five minutes.

 

 

Link to comment
Share on other sites

  • Administrators

Well you could do a couple of things here:

  • Use a nullable DateTime field that indicates the last time the query execute and if (DateTime.now - lastValue.Value).TotalMinutes == 5 (check for null before using .Value) then execute your query, otherwise ignore the call
  • On the constructor create a Thread or a Task that runs a while loop that checks for a variable that you set it to true when the plugin is unloaded. Use Thread.Sleep to delay the next execution.
  • On the constructor create a Timer that runs every 5 minutes. Don't forget to stop the time when the plugin is disabled.

I believe I've used custom timers in one of my plugins, why not check them out for sample code (all my plugins come with the source code included).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...