La respuesta a esta pregunta dependerá mucho de lo qué se refiere con recargar algo de información en ASP.NET Proyecto MVC. Este no es un problema claramente establecido y, como tal, más que obviamente, no puede tener una respuesta claramente establecida.
lo tanto, si suponemos que por este que desea sondear periódicamente alguna acción del controlador y actualizar la información en una vista que se podría utilizar el setInterval función javascript para sondear periódicamente el servidor mediante el envío de una petición AJAX y actualizar la interfaz de usuario:
window.setInterval(function() {
// Send an AJAX request every 5s to poll for changes and update the UI
// example with jquery:
$.get('/foo', function(result) {
// TODO: use the results returned from your controller action
// to update the UI
});
}, 5000);
Si por el contrario te refieres a la ejecución de alguna tarea en el servidor a intervalos regulares se puede utilizar el método de RegisterWaitForSingleObject así:
var waitHandle = new AutoResetEvent(false);
ThreadPool.RegisterWaitForSingleObject(
waitHandle,
// Method to execute
(state, timeout) =>
{
// TODO: implement the functionality you want to be executed
// on every 5 seconds here
// Important Remark: This method runs on a worker thread drawn
// from the thread pool which is also used to service requests
// so make sure that this method returns as fast as possible or
// you will be jeopardizing worker threads which could be catastrophic
// in a web application. Make sure you don't sleep here and if you were
// to perform some I/O intensive operation make sure you use asynchronous
// API and IO completion ports for increased scalability
},
// optional state object to pass to the method
null,
// Execute the method after 5 seconds
TimeSpan.FromSeconds(5),
// Set this to false to execute it repeatedly every 5 seconds
false
);
Si quieres decir algo más, no Hesi para proporcionar más detalles a su pregunta.
necesitamos más detalles sobre lo que está tratando de hacer – rboarman
¿Puede enumerado las varias maneras para que podamos dar nuestra opinión? –
¿Por qué no una aplicación por separado? –