Which is better, a scheduled task or windows service? [closed] - c#

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have created a console program that transfers data from a database to a server. This program must run every day at a certain time. At first I thought of a scheduled task but the problem is that it depends on a user being logged in. However, as it is rather tricky and the service has to run every day, I came to the Windows service through my research.
However, most of the information comes from 2009 and 2010 and may already be outdated? I also found a guide explaining how to create a scheduled service:
https://www.aspsnippets.com/Articles/Simple-Windows-Service-that-runs-periodically-and-once-a-day-at-specific-time-using-C-and-VBNet.aspx
Is that still best practice to do it that way? What would you recommend?

Your first thought was right, use a scheduled task and select the 'Run whether user is logged on or not'.
If you use a Windows Service you have to code the trigger yourself which could be fraught with errors.
If you'd like something more 'enterprise' I'd suggest looking at Quartz.NET. It's an open source scheduling library, although it's probably overkill for what you're trying to achieve.

Related

Timer for sending request at some time period [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have specific trouble: I'm using Yandex.Disk cloud storage and working with this by Yandex.Disk REST API. I have some functionality for syncing data and saving to db. Specially it's file name, file md5, file download url. But trouble is that download url is temporary. And I'm looking for solution, to have ability for apdating download url for all saved in db files, each 24 hours. First solution I found is another project that will be launching by windows task scheduler, but my hosting provider not giving this ability. Help me please to find good solution for this.
You can probably use hangfire http://hangfire.io/ to create a recurring task within your ASP.NET application.

Infinite running client [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
what I want to do is write a program that listens wcf web service frequently , say once every half-hour, and updates db according to ws result.What is the proper way of writing that kind of program.Should I create an exe and make it a windows scheduled task or write a program that has an infinite loop , maybe a thread approach.What is your opinion ?
Thank you for any help.
You probably have to create a Windows Service Application:
Microsoft Windows services, formerly known as NT services, enable you
to create long-running executable applications that run in their own
Windows sessions. These services can be automatically started when the
computer boots, can be paused and restarted, and do not show any user
interface. These features make services ideal for use on a server or
whenever you need long-running functionality that does not interfere
with other users who are working on the same computer.
In order to implement a recurring event, you need to use the Timer Class.
On a second thought, supported by these references:
windows service vs scheduled tasks
Windows Service or Scheduled Task, which one do we prefer?
//TODONT: Use a Windows Service just to run a scheduled process
a scheduled task seems also a nice solution which fits your scenario.
In terms of available .NET libraries, there is no difference between the 2 alternatives.

C# solution to always check for a specific condition in system [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
In my system, I have to send sms to users whose accounts are expired on the day of expiration. So I'm thinking of a solution to check all accounts everyday regardless of other functionality of the server so I was guessing a service should do the job? I'm looking for the best practice.
If you have a task that you want to run once a day, a service is not necessary. You can simply use the Task Scheduler to schedule a task thats run your C# program at the same time each day.
That way you don't have to do the extra work of writing a service, and you don't have a process running all the time that just sits there waiting all day.
you can use a service that send sms and call that when accounts is expired on the day of expiration

asp.net MVC automatic sending mail every day (without windows service) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am searching for the best way to create a automatic mail system which fires every day (e.g. 00:00:00) and sends a list of mails.
Which is the best option to perform this task without slow down my application or harm to the server.
I don't want to use windows service to achieve this task. because i am using a shared windows hosting and they don't allow me to run it on the server
Thank you.
Which database do you use ? If its MS Sql Server You can use
THE sp_send_dbmail as a part of a stored procedure to send email.
http://technet.microsoft.com/en-us/library/ms190307.aspx
You can then set up the stored procedure as a Sql Server Agent job to run at regular intervals as shown below
http://www.c-sharpcorner.com/UploadFile/raj1979/create-and-schedule-a-job-in-sql-server-2008/
You could put WCF service with Quartz.NET http://quartznet.sourceforge.net/ aboard on the same IIS or on another machine.
This approach also allows you to have API to control your scheduler.
Regrads.

Multithreading advice on approach needed [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have been told to make a process that insert data for clients using multithreading.
Need to update a client database in a short period of time.There is an application that does the job but it's single threaded.Need to make it multithread.
The idea being is to insert data in batches using the existing application
EG
Process 50000 records
assign 5000 record to each thread
The idea is to fire 10-20 threads and even multiple instance of the same application to do the job.
Any ideas,suggestions examples how to approach this.
It's .net 2.0 unfortunately.
Are there any good example how to do it that you have come across,EG ThreadPool etc.
Reading on multithreading in the meantime
I'll bet dollars to donuts the problem is that the existing code just uses an absurdly inefficient algorithm. Making it multi-threaded won't help unless you fix the algorithm too. And if you fix the algorithm, it likely will not need to be multi-threaded. This doesn't sound like the type of problem that typically benefits from multi-threading itself.
The only possible scenario I could see where this matters is if latency to the database is an issue. But if it's on the same LAN or in the same datacenter, that won't be an issue.

Categories