473,387 Members | 1,585 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.

worker thread - how to?

Hi;

I need to have a worker thread that awakens every 15 minutes and then sends
some emails (sometimes).

1) What is the best way to set up the worker thread?

2) How do I access the IIS smtp server to send an email?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Jun 22 '06 #1
6 1059
Hi David,

Thank you for your post.

I think you can use a Timer and store it in Application states:

void Application_Start(object sender, EventArgs e)
{
Timer t = new Timer(3000);
t.Enabled = true;
t.Elapsed += new ElapsedEventHandler(t_Elapsed);
Application["timer"] = t;
}

void t_Elapsed(object sender, ElapsedEventArgs e)
{
...
}

Regarding sending email, you can use SmtpClient from System.Net.Mail
namespace.

Unlike System.Web.Mail, which was introduced in the 1.0 Framework,
System.Net.Mail is not built upon the CDO/CDOSYS libraries. Instead it is
written from the ground up without any interop. Thus, it is not dependant
upon on other COM libraries. Although some functionality has been removed,
the new System.Net.Mail namespace is much more versatile than the older CDO
dependant System.Web.Mail.
SmtpClient mailObj = new SmtpClient( "name of the host");
MailMessage mail = new MailMessage("x...@yahoo.co.in",
"x...@hotmail.com", "Testing", "Hello Everybody");
mailObj.Send(mail);

You can also config the Host, Credentials and Port properties for
SmtpClient by using the settings in the application or machine
configuration files. For example:

<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network
host="localhost"
port="25"
defaultCredentials="true"
/>
</smtp>
</mailSettings>
</system.net>
</configuration>

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 22 '06 #2
Perfect. This is what I thought it was but I figure better to ask in case
there is a better way.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

"Walter Wang [MSFT]" wrote:
Hi David,

Thank you for your post.

I think you can use a Timer and store it in Application states:

void Application_Start(object sender, EventArgs e)
{
Timer t = new Timer(3000);
t.Enabled = true;
t.Elapsed += new ElapsedEventHandler(t_Elapsed);
Application["timer"] = t;
}

void t_Elapsed(object sender, ElapsedEventArgs e)
{
...
}

Regarding sending email, you can use SmtpClient from System.Net.Mail
namespace.

Unlike System.Web.Mail, which was introduced in the 1.0 Framework,
System.Net.Mail is not built upon the CDO/CDOSYS libraries. Instead it is
written from the ground up without any interop. Thus, it is not dependant
upon on other COM libraries. Although some functionality has been removed,
the new System.Net.Mail namespace is much more versatile than the older CDO
dependant System.Web.Mail.
SmtpClient mailObj = new SmtpClient( "name of the host");
MailMessage mail = new MailMessage("x...@yahoo.co.in",
"x...@hotmail.com", "Testing", "Hello Everybody");
mailObj.Send(mail);

You can also config the Host, Credentials and Port properties for
SmtpClient by using the settings in the application or machine
configuration files. For example:

<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network
host="localhost"
port="25"
defaultCredentials="true"
/>
</smtp>
</mailSettings>
</system.net>
</configuration>

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 22 '06 #3
one note. application_start will not fire until someone hits your site. also
the asp.net default is to automactally shutdown the site if there is no
usage. not a problem if you have a high volumne site.

-- bruce (sqlwork.com)


"David Thielen" <th*****@nospam.nospam> wrote in message
news:8D**********************************@microsof t.com...
Perfect. This is what I thought it was but I figure better to ask in case
there is a better way.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

"Walter Wang [MSFT]" wrote:
Hi David,

Thank you for your post.

I think you can use a Timer and store it in Application states:

void Application_Start(object sender, EventArgs e)
{
Timer t = new Timer(3000);
t.Enabled = true;
t.Elapsed += new ElapsedEventHandler(t_Elapsed);
Application["timer"] = t;
}

void t_Elapsed(object sender, ElapsedEventArgs e)
{
...
}

Regarding sending email, you can use SmtpClient from System.Net.Mail
namespace.

Unlike System.Web.Mail, which was introduced in the 1.0 Framework,
System.Net.Mail is not built upon the CDO/CDOSYS libraries. Instead it is
written from the ground up without any interop. Thus, it is not dependant
upon on other COM libraries. Although some functionality has been
removed,
the new System.Net.Mail namespace is much more versatile than the older
CDO
dependant System.Web.Mail.
SmtpClient mailObj = new SmtpClient( "name of the host");
MailMessage mail = new MailMessage("x...@yahoo.co.in",
"x...@hotmail.com", "Testing", "Hello Everybody");
mailObj.Send(mail);

You can also config the Host, Credentials and Port properties for
SmtpClient by using the settings in the application or machine
configuration files. For example:

<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network
host="localhost"
port="25"
defaultCredentials="true"
/>
</smtp>
</mailSettings>
</system.net>
</configuration>

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Jun 22 '06 #4
Thanks Bruce on this.

Hi David, if this is the issue, you may use Windows Service to do the job.
Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 23 '06 #5
I think we're fine doing it in ASP.NET but the services is a good idea if we
every need it running 100% of the time.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

"Walter Wang [MSFT]" wrote:
Thanks Bruce on this.

Hi David, if this is the issue, you may use Windows Service to do the job.
Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 23 '06 #6
Hi David,

Thank you for your update.

Please let me know if you need help on Windows Service programming.

Have a nice day!

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 23 '06 #7

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

Similar topics

2
by: Mark Hoffman | last post by:
All, My application spawns a worker process by calling BeginInvoke with an asynchronous callback method. This callback method is responsible for calling EndInvoke. No problems there; pretty much...
5
by: Stephen Lamb | last post by:
I have a background worker thread which I start from a form's HandleCreated event that makes calls back to the form using Invoke. During shutdown the form is disposed and the background worker...
7
by: Jeff Stewart | last post by:
I need a thread to run a subroutine which updates my main form's progress bar. I've properly marshaled all UI updates to the main UI thread, and after the main thread starts the worker thread, it...
7
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have...
6
by: Joe Jax | last post by:
I have an object that spawns a worker thread to process one of its methods. That method processes methods on a collection of other objects. During this processing, a user may request to cancel the...
5
by: Soren S. Jorgensen | last post by:
Hi, In my app I've got a worker thread (background) doing some calculations based upon user input. A new worker thread might be invoked before the previous worker thread has ended, and I wan't...
14
by: joey.powell | last post by:
I am using VS2005 for a windows forms application. I need to be able to use a worker thread function to offload some processing from the UI thread. The worker thread will need access to a...
0
by: =?Utf-8?B?aGVyYmVydA==?= | last post by:
I read from a serialport using a worker thread. Because the worker thread t does not loop often, I cannot wait to terminate the worker thread using a boolean in the While condition. So I have a...
4
by: dgleeson3 | last post by:
Hello all Yes I know its been done before, but something silly is killing me on this. I have the standard progress bar and worker thread scenario with progress of the worker thread being fed...
1
by: nicerun | last post by:
I'm using the Application_Start event at Global.asax.cs to invoke thread that do some job. I know that Application_Start event occurs when the very first request to Web Application received. -...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.