itnifl
asked on
Querying the status of an object in C# MVC from jQuery
I have the following method in a C# MVC controller that gets called by jQuery Ajax:
e() is running, I can step through the execution and the database gets updated. But it seems that each time when I query the controller with ajax, then lEngine is reinitialized to a different instance of itself while the original lEngine is doing it's job.
I would like to start an instance of lEngine that I can query the status of, so that I can inform via the UI how the job is going.
[HttpGet]
public void SyncLDAPUsers() {
Task.Factory.StartNew(() => {
lEngine.SyncUsersToDatabase();
});
}
[HttpGet]
public ActionResult GetLDAPSyncItemsOverview() {
return Json(new { SyncMaxItems = lEngine.SyncMaxItems, SyncCurrentItemCount = lEngine.SyncCurrentItemCount, SyncStatus = lEngine.SyncStatus, SyncedNameList = lEngine.SyncCurrentNames }, JsonRequestBehavior.AllowGet);
}
SyncLDAPUsers gets called first and starts the sync of ldap users to the local database. Then I have a deferred javascript function, that polls via setInterval on to GetLDAPSyncItemsOverview every 4 seconds. It is supposed to retrieve the sync status and update the UI with the names that have been synced (SyncedNameList). But the list is always empty, and SyncMaxItems and also SyncCurrentItemCount is always the initial value 0. I know that lEngine.SyncUsersToDatabasI would like to start an instance of lEngine that I can query the status of, so that I can inform via the UI how the job is going.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER