473,407 Members | 2,546 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,407 software developers and data experts.

How to shutdown VB.net (Windows Service) without data loss?

2
Hi All,

I'm a starting VB.net programmer and have found a lot of usefull tips on this website, thanks for that!
So maybe somebody can give me some advise on my challenge.

I wrote a Console Application in VB.net 2005 Express which gets data from a MySQL-database and converts it to several CSV-files. It marks the data that has been converted to CSV-file and finally moves the data from a temporary directory to a final directory where it is processed by another application.
As a standard Console Application it works fine at a single trigger.

Now the application must run once every 15 minutes even if nobody has logged on to the server (2003).

So I want to convert the application to a Windows Service, for this I followed a small tutorial on dotheweb.net.
But now I have a question about shutting down the application.

How can I guarantee that when the service stops, my program finishes? If the application stops before updating the table but created allready the files I could have incomplete data!

Do I have to work with threads, or are there any other solutions?
Or should I use the taskscheduler? What happens here when the application is forced to stop?

Thank you.

VBQ
Feb 3 '08 #1
2 1659
Shashi Sadasivan
1,435 Expert 1GB
A windows service has events called starting, stopping
You should be able to code your requirements in the stopping event
You can cancel the stopping of the service if your program has not yet finished processing.

However in an event of a power failure, im not sure what this would do.
Feb 4 '08 #2
VBQ
2
A windows service has events called starting, stopping
You should be able to code your requirements in the stopping event
You can cancel the stopping of the service if your program has not yet finished processing.

However in an event of a power failure, im not sure what this would do.
Shashi, thanks for your reply.

How do I cancel stopping? Are there examples available as far as you know?
And in what can I determine that my program is still running? I could use a variable for this, but I think there must be a better way, like threads?

Good point about power failure, but I don't really fear a power failure, because I use a smart UPS. But I will keep this in mind!
Feb 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Jonathan Heath | last post by:
Hi all, I have created an ASP script that enters data into an Access Database. My problem is that I'd like this script to run when the computer is shutdown or the user logs off. I think...
4
by: Bill Sonia | last post by:
I'm written a Windows Service to send e-mails on events like OnStart, OnStop, OnShutDown using System.Web.Mail. It works for everything but OnShutdown. My guess is that once my send mail code is...
8
by: Bill Sonia | last post by:
I've written a Windows Service to send e-mails on events like OnStart, OnStop, OnShutDown using System.Web.Mail. It works for everything but OnShutdown. My guess is that for OnShutDown, once my...
6
by: carbon_dragon | last post by:
Ok, so here is the problem. I'm working on a headless server program implemented as a .NET C# Console project. There is a UPS mounted to this server (though not a windows compliant UPS). I can only...
0
by: Stefan Krah | last post by:
Hello, I'm trying to run a Python script as a Windows service with a defined shutdown. The script (enigma-client.py) handles the communications with the server in a distributed computing effort...
6
by: Ash | last post by:
Hi coders, I have a service that does alot of data copying to the database and when the service is stopped or the machine is shutting down it commits the data (in addition to other things) and...
5
by: Phil Tusa | last post by:
Greetings to all .... I have a need to issue a shutdown and/or Restart Windows XP inside my application. Any help or example code would be appreciated! -- Phil
13
by: José Joye | last post by:
Hello, What is the best way to stop a remoting server (Singleton SAO) that has been started with RemotingConfiguration.Configure(). For sure, I want to do this without quitting the application...
10
by: tshad | last post by:
I have a Windows Service that I need to put to sleep for about 10-20 minutes. The problem is that if you try to shut it down during this time, it will tell you that the service didn't respond in...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.