Link to home
Start Free TrialLog in
Avatar of vikasbapat
vikasbapat

asked on

How to perform some transactions on system startup in C# .net(windows application)?

Hi,

In my C# windows appllication , I want to perform some transactions on system startup
and atleast once in 24 hour when running for prolonged periods of time.
How to get  system startup time?
Or
Can I use Windows Services to set timers? how?  


Please help me.
Avatar of Gautham Janardhan
Gautham Janardhan

u could use the windows services project and do this

u could configure to auto run the service at start up and i think this would solve the problem :-)
In .Net framework library the System.ServiceProcess namespace provides classes that allow you to implement, install, and control Windows service applications. To implement a service we need to inherit from ServiceBase class.
For installing a service, .Net provides a utility called installutil.exe which installs the service and registers it with Service Control Manager(SCM)




ASKER CERTIFIED SOLUTION
Avatar of Gautham Janardhan
Gautham Janardhan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You just have some parameters in the applicatoin config file or in the registry,

DateTime AppStarted;
DateTime TransactionLastRun;
TimeSpan TransactionPeriod;

When the app starts it checks the TransactionLastRun and if the timespan between then and now is greater than the timspan TransactionPeriod thew run the transaction update the TransactionLastRun and the AppStarted.
Then start a timer that will check avery given period to see if 24 hours have elapsed since AppStarted and if they have run the transaction again.
You do not need a windows service for this kind of thing. It's overkill.
<system startup > not application start up