|
PIEBALDconsult wrote: No, this is a democracy, anyone can vote any way they please.
Why should someone vote down a good answer? Even if someone does, a new comer might think that it is a bad answer based on the rating, and that is one of the purposes why rating systems exist.
|
|
|
|
|
Shameel wrote: Why should someone vote down a good answer?
Alas, there are feuds and rivalries and pettiness.
|
|
|
|
|
PIEBALDconsult wrote: Alas, there are feuds and rivalries and pettiness.
Yes, unfortunately there are. But ideally, they should have no place in a technical forum like this.
|
|
|
|
|
Covean wrote: So at last: I never said your answer is wrong, but 3 times the same sh... after the OP queried for some alternatives.
It might be sh** to you, not to the OP. This is what the OP wrote sometime ago to another post in this thread.
"Dear all,
Thanks a lot for usefull responses.
Im very new in this and i thought that a windows service is the solution for my project.
My application had to import some data from network once a day, save it to our db and export it to some other relations.
Bud i will discuse your suggestions with my coworkers.
Thanks a lot."
It means the OP is ready to explore the idea of using task sheduler.
And do you seriously believe that Windows Service exists to do this kind of work ?
|
|
|
|
|
I want to apologize myself for voting you down.
... every following word is just destructive ...
Greetings
Covean
|
|
|
|
|
So, you now atleast agree that you tried to push her out of the window when most of others tried to show her the elevator
|
|
|
|
|
Covean wrote: the OP said it has to be a service
But we were able to read between the lines and determine that that is not actually what the OP needed and therefore we were able to suggest a better solution than that which was asked for in the post. This happens quite a bit here; less-experienced developers may not know all the tools available to them. By recommending better techniques the developer's skillset is broadened, and that's a good thing.
|
|
|
|
|
We are here to help other developers become the best they can be. In many cases, what the poster thinks he wants to do is not the best course of action. Using the Task Scheduler is the better technique based on what was in the post. The poster gave no reasons for the requirement of being a Service or why it could not be a Task. I, for one, therefore assume that he does not know about the Task Scheduler and why it is (probably) a better solution for his needs. If he has at least considered using a Task, but still insists on a Service, then so be it. I, myself, have written a task scheduler as a Service -- but it didn't execute only one task once a day, it executed many at various times, and I eventually stopped using it.
If a person wanted to jump off a tall building just to get to the ground I wouldn't push him; I'd recommend the elevator instead.
|
|
|
|
|
Sorry have you ever read my post and all postings before?
In one answer he said it has to be a service long time before the poster of this subthread ever answered.
Next point: There were 2 other persons who told before that he should use the task planer, so why the hell should someone answer the question a third time with an answer the OP can't use???
Thats exactly the reason why I voted with 1.
At least one point to think about: What are the differences between a service and an application
started by the task planer (what itself is a service!)?!
Greetings
Covean
|
|
|
|
|
What is the problem with it.
Just use
Thread.Sleep , to sleep the current thread for a time which wakes up only at 12:00 AM. Calculate the time seed needed from current time to this time, and sleep for that. Now reset the seed for 24 hrs and apply thread.sleep again (infinitely)
If the process restarts again, it will do the calculation to find the sleep value.
|
|
|
|
|
Only use Thread.Sleep will not solve the problem because this thread doesn't react on service requests and at least it should react on stop request.
Greetings
Covean
|
|
|
|
|
<DevilsAdvocate>The OnStart could spawn off a Thread that Sleeps and the OnStop could Abort that Thread.</DevilsAdvocate>
|
|
|
|
|
Oh yes I also think its a very good habit to abort your threads!
Greetings
Covean
|
|
|
|
|
Sleeping for 86400000 milliseconds is not a good idea.
|
|
|
|
|
You are right...
Thread.Sleep is not a good thing to use. I just gave an alternate solution as the person dont wants to use an already existing scheduler service...
If he is smart, he should also able to point this himself.... .
|
|
|
|
|
You'd prolly want a service, so that you won't have to log in to the machine. Then again, a service that keeps polling the time to do an action once a day would be wasting a lot of resources. Still, it's an easy solution, and makes for easy maintenance - and an interval of a minute wouldn't waste that much.
There's an article here on writing your own application-scheduler as a Windows-service.
Good luck
I are Troll
|
|
|
|
|
Eddy Vluggen wrote: You'd prolly want a service, so that you won't have to log in to the machine.
You don't have to log in to the machine for a scheduled task either. I agree with the other posters: I don't really understand why this has to run as a service rather than a scheduled task. But if that is what the OP wants, it can be done.
|
|
|
|
|
David Skelly wrote: You don't have to log in to the machine for a scheduled task either.
Cool, you're right! The scheduler is already a service, hence it is already running.
The logon-problem shot in my mind as an argument for wanting a service over a console-application. I was guessing why the OP didn't want to use a console, whilst I could simply ask "why not?"
David Skelly wrote: But if that is what the OP wants, it can be done.
Knowing what you want can be quite difficult
--edit--
the +5 is for teaching me something new
I are Troll
|
|
|
|
|
Dear all,
Thanks a lot for usefull responses.
Im very new in this and i thought that a windows service is the solution for my project.
My application had to import some data from network once a day, save it to our db and export it to some other relations.
Bud i will discuse your suggestions with my coworkers.
Thanks a lot.
|
|
|
|
|
I would definitely look into the Task Scheduler for that, because it gives you much more flexibility in terms of when the task runs. It also gives you the ability to view when the task last ran, etc. Your importer application would be a straightforward console application that gets invoked when required by the scheduler. Easier for testing, as well, because that way you can run the import from the command line whenever you want to test it without having to fiddle around with the settings on a service.
If you do decide to go down the service route, all you need is a timer that fires off at fixed intervals (e.g. once a minute) to check the time to decide when to run your import. Unfortunately the VB.NET Timer class does not allow you to schedule an event for a particular time (that has always seems to me to be a bit of an obvious oversight but I guess that takes us back to the Task Scheduler). If you use Thread.Sleep on the main thread of your service be aware that will block the thread and you will not be able to shut it down unless it wakes up occasionally to check for a stop request.
|
|
|
|
|
A Windows Service is a worst choice for your requirement. If you had spelled out your requirements in the original post, you'd have got better answers earlier.
I have an application that does exactly this:
1. The data comes as a text file feed.
2. An SSIS package (SQL Server Integration Services) loads the contents of this file to the database. It is first loaded "as is" in a staging database. Then the SSIS package executes a stored procedure that reads the staging database, does all the required transformations, calculations, etc. and loads the transformed data into the actual application database.
3. An SQL Server job executes the package at a specified time once a day, typically at midnight since no one will be using the database at that time.
Try something on these lines.
|
|
|
|
|
Priya Prk wrote: import some data
If you are using SQL Server you may be able to use the bcp utility. In which case, you need only write a format file and a command file. If you need help with that, you can ask questions in the database forum.
Other databases may also have import utilities.
|
|
|
|
|
There are two applications, one is 64 bit and another one is 32 bit
1, I need to use 64 bit app to launch 32 bit one, how to implement it?
2, Is it possible to access the functions in 32 bit app from 64 bit
Thanks you in advance
|
|
|
|
|
jsjwql123 wrote: 1, I need to use 64 bit app to launch 32 bit one, how to implement it?
Look at the Process.Start() method.
jsjwql123 wrote: 2, Is it possible to access the functions in 32 bit app from 64 bit
No, you cannot mix 32-bit and 64-bit code in the same process.
|
|
|
|
|
He is already asking for two process. So, it is possible, but you must use some kind of RPC/Remoting.
|
|
|
|