M
moo
A fascinating discussion on "Threads in asp.net" (http://
groups.google.com/group/microsoft.public.dotnet.languages.csharp/
browse_thread/thread/f5a8fc4eed6d2d8f/5bee26eb7f1274d6?
lnk=gst&q=threads+in+asp.net#5bee26eb7f1274d6) from moons ago says
that the ASP.NET worker process handles all sites concurrently in the
worker process thread pool...I'm curious how that statement stands up
to newer versions of the framework (I'm targeting 3.0).
I have a form that I want a user to fill out with information, then I
want to generate a report to e-mail to an overseer with the form's
contents. I'm trying to be cute and dynamic about it, and have created
a snippet as follows:
protected void btnSubmit_OnClick(Object sender, EventArgs e)
{
List<string> formContents = new List<String>();
foreach (AccordionPane pane in IntakeAccordion.Panes)
{
foreach (Control conty in pane.ContentContainer.Controls)
{
if (conty.Visible) //assume irrelevant controls aren't
visible...
{
if (conty.HasControls())
formContents.Add(getChildContents(conty));
//Need to go back and change plain text HTML
prompts into Labels...there was a method behind my madness in the
first place!
formContents.Add(getControlValue(conty));
}
}
}
string fileName = System.IO.Directory.GetCurrentDirectory() +
txtFirstName.Text + "_" + txtLastName.Text +"_IntakeReport.doc";
//I may not need to do this, but I think on the web if I have
two people entering the same client name at the same time and they
happen to click this button, I might create a race condition...this is
probably the best approach
lock(this)
{
//This is why C# is ****ing awesome! Take a dynamic list
of created contents, and in two lines make it an array and use a
library function to achieve complex functionality...thank you for
making my life not suck!
System.IO.File.WriteAllLines(fileName,
formContents.ToArray());
}
EmailOverseer(fileName);
}
My question is: do I need that lock? My initial feeling is that since
I'm creating a file name based upon the names entered in the fields (I
should probably sanitize those inputs..aside from regexs looking for A-
Z, any other checking ideas I should do would be welcome), I may
someday have the odd condition where two users are entering
information for the same person and happen to click the button at the
same time, possibly creating a race condition. Is that accurate?
groups.google.com/group/microsoft.public.dotnet.languages.csharp/
browse_thread/thread/f5a8fc4eed6d2d8f/5bee26eb7f1274d6?
lnk=gst&q=threads+in+asp.net#5bee26eb7f1274d6) from moons ago says
that the ASP.NET worker process handles all sites concurrently in the
worker process thread pool...I'm curious how that statement stands up
to newer versions of the framework (I'm targeting 3.0).
I have a form that I want a user to fill out with information, then I
want to generate a report to e-mail to an overseer with the form's
contents. I'm trying to be cute and dynamic about it, and have created
a snippet as follows:
protected void btnSubmit_OnClick(Object sender, EventArgs e)
{
List<string> formContents = new List<String>();
foreach (AccordionPane pane in IntakeAccordion.Panes)
{
foreach (Control conty in pane.ContentContainer.Controls)
{
if (conty.Visible) //assume irrelevant controls aren't
visible...
{
if (conty.HasControls())
formContents.Add(getChildContents(conty));
//Need to go back and change plain text HTML
prompts into Labels...there was a method behind my madness in the
first place!
formContents.Add(getControlValue(conty));
}
}
}
string fileName = System.IO.Directory.GetCurrentDirectory() +
txtFirstName.Text + "_" + txtLastName.Text +"_IntakeReport.doc";
//I may not need to do this, but I think on the web if I have
two people entering the same client name at the same time and they
happen to click this button, I might create a race condition...this is
probably the best approach
lock(this)
{
//This is why C# is ****ing awesome! Take a dynamic list
of created contents, and in two lines make it an array and use a
library function to achieve complex functionality...thank you for
making my life not suck!
System.IO.File.WriteAllLines(fileName,
formContents.ToArray());
}
EmailOverseer(fileName);
}
My question is: do I need that lock? My initial feeling is that since
I'm creating a file name based upon the names entered in the fields (I
should probably sanitize those inputs..aside from regexs looking for A-
Z, any other checking ideas I should do would be welcome), I may
someday have the odd condition where two users are entering
information for the same person and happen to click the button at the
same time, possibly creating a race condition. Is that accurate?