简体   繁体   中英

asp mvc reload page every 30 seconds when browser is minimized

Actually we Play a notification sound when some update happens in database, so I am trying to reload a ActionMethod every 30 seconds when browser in minimized, this works fine in Firefox , but in Chrome this doesn't work.

Scenario:

Minimize the browser and leave the computer idle.

I have tried two methods:

Method 1:

   <meta http-equiv="refresh" content="30;URL=http://example.com/" />

Method 2:

 <script>

   $(document).ready(function () {

   setTimeout(function(){
    window.location.reload(1);
    }, 30000);

    });

 </script>

After reading this post , It seems when Chrome is minimized it sets Javascript setInterval and setTimeout to an idle state, because browser performance improvements affects the executions of Javascript intervals.

So Can i use Scheduled Tasks like FluentScheduler , Quartz.NET or Hangfire to reload a ActionMethod every 30 seconds ?

Any help would be great.

SignalR is a perfect match here. Why do you want your clients to be sending request to the server every 30 seconds? This is likely to hit your performance and increase your server load.

Instead I would suggest using SignalR and pushing notification to the client whenever there is any update.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM