javascript - Update site automatically by calling a function -
i building news website using asp.net. want updated automatically pulling new news articles. done calling function downloads updated json string.
how call function every half hour in c#? or should write function in javascript , call every half hour?
you can use timer in c#
protected void page_load(object sender, eventargs e) { // create timer system.timers.timer mytimer = new system.timers.timer(); //call method mytimer.elapsed += new elapsedeventhandler(mymethod); //time interval 5 sec mytimer.interval = 5000; mytimer.enabled = true; } public void mymethod(object source, elapsedeventargs e) { //your code }
also, can use settimeout function in javascript
settimeout(function() { //calls click event after time that.element.click(); }, 5000);
or
use task this
task.factory.startnew(() => { system.threading.thread.sleep(5000); callmethod(); });
Comments
Post a Comment