Need suggestion on background worker

I want to develope a delivery application(self hosted WCF service ) which allows scheduling of the emails. User will assign a schedule to email and send it. The WCF service should be able to pick the email and send it on its scheduled time.

What approach shall I use here? I am thinking about following alternatives

  1. Use background worker thread to perform this task
  2. Any third party scheduling service (I yet to investigate on this)

Can anyone suggest me a possible solution for this apart from above mentioned two?

[Edit] : Can I use SQL Agents for this?

Thanks,

Ram

Answers


I saw the "...apart from above mentioned two..." but I think there is nothing else to achieve this :) Either build an infinite loop inside of windows service like this:

private void DoTheThing()
    {
        try
        {
            while (true)
            {
                TheThing e = new TheThing();
                Thread t = new Thread(new ThreadStart(e.Run));
                t.Start();
                Thread.Sleep(1000);
            }
        }
        catch (ThreadAbortException) { }
        catch (Exception ex) { /* Whatever error handling you got */ }
    }

... where TheThing has a method Run which does all that you need every 1 second. This looks silly (while(true) - yeah, right) but has been working non-stop since .NET 1.0 on at least 30 servers :) Just make sure you call this DoTheThing method on Start of your windows service in a new thread.

Hope this helps :)


Have your WCF service queue the email requests either to a database table. Then write a Windows service that periodically scans the table, sends the email, and then update the table with the results.

If you're using a SQL Server, you can send emails directly from it and also schedule jobs to send the emails, saving you from having to deploy a Windows service.


Need Your Help

Cleanning a String from html code and accents with java

java regex string diacritics non-ascii-characters

I need to clean an html string from accents and html accents code, and of course I have found a lot of codes that do this, however, none seems to work with the file i need to clean.

Javascript Collision Detection between circle and polygon?

javascript math collision-detection

I'm unsure how to go about defining the area for a collision detection function when I have a polygon that looks like:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.