473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Is Threading Possible in an ASP.NET 1.1 Web Page?

Hi,

I am trying the following code with no success. Any input would be
appreciated.
private void InsertMsg( )

{

//do some stuff and then send an email in a new thread because our mail
server is slow many times and I want to redirect without waiting for email
to complete

Thread t = new Thread(new ThreadStart(Send_Email));

t.Priority = ThreadPriority.Highest;

t.Name = "MailThread";

t.Start();

Response.Redirect("threads.aspx?TopicID=" +
Request.QueryString["TopicID"] + "&TopicName=" +
Request.QueryString["TopicName"]);

}//End Function InsertMsg()

private void Send_Email()

{

//function sends email via SMTP

}

I tried creating and strting the thread in Page_Unload event but that didn't
work either.

Thanks for any input
Jan 5 '07 #1
2 1007
Try declaring your thread outside the method. Once the method ends, that
thread should be de-allocated since its scope is being destroyed, so if it
doesn't finish before that request call is done, it's gonna end as well.
I'd either declare a worker thread member in your class or spawn off a
worker thread via ThreadPool (it'll be more efficient than
creating/destroying threads every time)
Jan 5 '07 #2
There's no reason why that code should fail. How do you know it is failing?
Don't set the thread priority to highest, that's a bad practice, leave it as
normal. Also, you should be using a thread pool for this, it will put a cap
on the number of threads being used. On a heavy day, that code will likely
bring down the server. Also, you need to remove the response redirect line
from that function. It isn't logically related to inserting a message.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc

"Frank" <fk******@pfmail.comwrote in message
news:uV**************@TK2MSFTNGP03.phx.gbl...
Hi,

I am trying the following code with no success. Any input would be
appreciated.
private void InsertMsg( )

{

//do some stuff and then send an email in a new thread because our mail
server is slow many times and I want to redirect without waiting for email
to complete

Thread t = new Thread(new ThreadStart(Send_Email));

t.Priority = ThreadPriority.Highest;

t.Name = "MailThread";

t.Start();

Response.Redirect("threads.aspx?TopicID=" +
Request.QueryString["TopicID"] + "&TopicName=" +
Request.QueryString["TopicName"]);

}//End Function InsertMsg()

private void Send_Email()

{

//function sends email via SMTP

}

I tried creating and strting the thread in Page_Unload event but that
didn't work either.

Thanks for any input


Jan 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matteo Memelli | last post by:
Hi, I'd like to know if it is possible to use the threading module to benchmark a web server. I'd like to write a python script which connect to a web server asking for a page (like a php page...
8
by: Yatharth | last post by:
Hi, I m new to threading and i have successfully runed threading but i could display value on my web page ,but its working in code behind when i see it through debugger,plzzzzzzz help me here...
3
by: JMax | last post by:
Hello! I have a C# ASPX page that displays a large amount of information. The software loops through 500 lines of code (and some of the 500 lines are looped multiple times, in a loop)....
1
by: James | last post by:
Simple concept. I have a stored procedure call that takes a very long time to run. This is a necessary evil. While this procedure is running, it does a simple update to a table with a %...
0
by: smimon | last post by:
Hi I'm trying to run a DTS package from a ASP.NET web page using System.Diagnostics.Process. This DTS takes up to 10 minutes to complete, during which, output is generated which i would like to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.