Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

My requirement:

I have more than one company in my database, which individually has more than 100 email-ids(i.e, client email-ids).

For each company I am creating a new thread and writing email-ids in a log file.

 

But the problem is, all the values are not written in the text file. Some data are missing, why it is so?

 

Code:

====

private void Page_Load(object sender, System.EventArgs e)

{

for (i=1; i<=10000; i++)

{

arrText.Add("email_" + i + "@hotmail.com");

}

 

sLogFilePath = "C:\\Documents and Settings\\NSPL\\Desktop\\logfile.txt";

FileStream fsLogFile = new FileStream(sLogFilePath, FileMode.OpenOrCreate, FileAccess.Write);

StreamWriter swLogFile = new StreamWriter(fsLogFile);

swLogFile.BaseStream.Seek(0, SeekOrigin.End);

swLogFile.WriteLine("Log file starts here\n");

 

for (i=1; i<=3; i++)

{

ThreadPool.QueueUserWorkItem(new WaitCallback(InstanceMethod), i.ToString());

}

}

 

public void InstanceMethod(object CompanyID)

{

for (j=0; j<arrText.Count; j++)

{

swLogFile.WriteLine(CompanyID.ToString() + " " + arrText[j].ToString() + "\n");

}

swLogFile.Flush();

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...