Posted September 23, 201410 yr  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.  Â
September 23, 201410 yr 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).
Create an account or sign in to comment