All to all,
I have an application that consumes several web services. What this application does that gets many users and creates entries in a .csv file for several projects.
I would like to do the execution for a certain amount of users, every 100 or 200 users the application wait about 30 seconds and continue its execution.
Let this be done until the execution is complete.
I want to avoid loading Querys into the database and prevent the traffic from getting saturated because I make several web calls.
How can I do that?
Thank you very much in advance.
Here is part of my code:
UserData[] userIds = GetUserID();
if (userIds.Length > 0)
{
List<string> multiUserIDs = new List<string>();
foreach (var userdata in userIds)
{
multiUserIDs.Add(userdata.List[0].ToString());
}
string testName = "test_";
string outCsvFile = string.Format(@"D:\TasksForAllProjects\{0}.csv", testName + DateTime.Now.ToString("_yyyyMMdd HHmms"));
String newLine = "";
var stream = File.CreateText(outCsvFile);
stream.WriteLine("ProjectName,UserFirstName,UserLastName,TaskStatus);
string temp = "";
var AllProjectIds = proj.ProjectID; //Esto viene de otra llamada hecha mas arriba
string[] projectIDs = new string[] { AllProjectIds }; // all projects
string singleUserID = "";
string[] taskStatus = new string[] { "notcompleted" };
TaskEntry[] result = GetTasks(projectIDs, singleUserID, multiUserIDs.ToArray(),taskStatus);
newLine = string.Format("\"{0}\",\"{1}\",\"{2}\"",
item.ProjectTitle,
item.UserID,
status);
//Creating a new file when new entries are found.
stream.WriteLine(newLine);
}
stream.Close();
I see that the problem could come from the variable multiUserIDs
which has all the users.
Then I should execute a number of users that comes from that variable.