I have RESTful service written in c#, its used to some internal data migration (SQL to Mongo) via some internal apis.
This REST service is getting SQL server data from web service and POST those data to another service which will insert data to mongo DB,
public void GetAllCoursesAndMigrateAllCourse(string clientstring, DataServiceCollection<Semester> semesters)
{
DataServiceCollection<Campus.Explorer.Proxy.Models.Course> courses = null;
try
{
string endpoint = campusExploreUri + clientstring;
CampusExplorerServiceContext campusExplorerServiceContext = new CampusExplorerServiceContext(new Uri(endpoint));
courses = new DataServiceCollection<Campus.Explorer.Proxy.Models.Course>(campusExplorerServiceContext.Courses);
if (courses != null && courses.Count > 0 && semesters != null && semesters.Count > 0)
ThreadPool.QueueUserWorkItem(new WaitCallback(f => { CreateCourse(courses, semesters); }));
int cCount =100;
//this step is necessary because CE results are limited to 100 per call. This will ensure we get all results
while (courses.Continuation != null)
{
courses = new DataServiceCollection<Campus.Explorer.Proxy.Models.Course>(campusExplorerServiceContext.Execute<Campus.Explorer.Proxy.Models.Course>(courses.Continuation.NextLinkUri));
if (courses != null && courses.Count > 0 && semesters != null && semesters.Count > 0)
{
cCount = cCount + courses.Count;
_logger.Info("cCount " + cCount);
ThreadPool.QueueUserWorkItem(new WaitCallback(k => { CreateCourse(courses, semesters); }));
}
}
}
catch (Exception ex)
{
_logger.Error("Error in GetAllCoursesAndMigrateAllCourse " + ex.Message);
}
}
Here I'm queuing all the get data to ThreadPool to process create course function. Once after get loop is over w3wp process is stopped the processing but w3wp process shows in task manager processes as idel, so because of this I'm loosing all the data are queued in Thredpool,
I have already removed the application pool recycle times and set the idle time to 0 in application pool settings.
How do I overcome this issue?