NetRaider Posted May 1, 2021 Share Posted May 1, 2021 (edited) How can I use or make a periodic event? Let's say I want to give money to players every 1 hour, just like a sign check. I did something, but it doesn't work, I used System.Threading; , but it crashes when I call a function from a main thread inside the background thread function... EDIT: It crashed because I was making logs.txt, I wrote down the solution for the logs.txt Edited May 4, 2021 by NetRaider Solved Link to comment Share on other sites More sharing options...
NetRaider Posted May 1, 2021 Author Share Posted May 1, 2021 (edited) Thanks to Mr.Duck @Jer who has helped me, here is the solution: https://docs.microsoft.com/en-us/dotnet/api/system.timers.timer?view=net-5.0 P.S. If you are using System.IO; to write down logs, make sure to put the code in this: NAPI.Task.Run(() => { // code here }); Edited May 1, 2021 by NetRaider Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now