473,698 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run a program repeatedly from another program



I want to add a program to windows which will run at a specified time
period which may be changed by the administrator.W hat I plan to do is
start the program at windows startup and then within that program check
for the correct time to run. Then when the time is equal to the seted
time another program is called Up to this point I can write code. But
after this I want the earlier program to check repeatedly and run the
second one at this interval.
How can I do this in C#?
Thanks in advance to all your help.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
4 1756
"Eranga" <km***@yahoo.co m> wrote:
[running a program periodically]


Use a Timer object, and inside the Tick event check whether the
desired time just passed.

Better yet, don't reinvent the wheel - use Scheduled Tasks in Windows
Control Panel.

P.
Nov 17 '05 #2
Hi,
By looking at ur requirement, I suggest you to create a windows
service.
You can find the source code for a similar windows service here:

http://www.c-sharpcorner.com/Code/20...nScheduler.asp

I hope it helps.

Regards,
MannY

Nov 17 '05 #3


But I can't use windows sheduled tasks because my time interval is not
fixed and can even be somthing like few minutes to several hours.
Also I have figured out a way to check time . My problem i srepeatedly
doing this. Because once it equals the program ends there.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #4
So..... basically you want an app to access a file or take an argument
to specify what the 2nd app run time delay is...? k

I would initilize the main app and use a System.Threadin g.Timer to
recall the 2nd app or preferably thread on that given time delay.

An example of how it works:

public class ....
{
public static void Main()
{
//Fire 20 secs from now, repeating at 25 sec intervals

new Timer(new TimerCallback(O nTimerFireMe), 42, new
TimeSpan(TicksP erSec*20), new TimeSpan(TicksP erSec*25) );
//Continue with other tasks
}

static void OnTimerFireMe(o bject arg)
{
int x (int)arg;
}
}

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
3599
by: edgrsprj | last post by:
PROPOSED EARTHQUAKE FORECASTING COMPUTER PROGRAM DEVELOPMENT EFFORT Posted July 11, 2005 My main earthquake forecasting Web page is: http://www.freewebz.com/eq-forecasting/Data.html Newsgroup Readers: If you circulate copies of this report to groups of computer programmers at different universities etc. around the world then they might find the subject matter to be interesting.
3
1767
by: Jason Heyes | last post by:
This is a revised version of a post entitled "Class to support keywords". Please reply to this post instead of the old one. The following program repeatedly prompts the user for C++ keywords until 'explicit' is entered. If the user fails to enter a valid keyword, the program terminates. #include <iostream> #include "KeyWord.h"
11
1603
by: | last post by:
I repeatedly get into the situation where i need to take action accordingly to input in form of a char*, and have found two manners of approaching this, i'd appretiate pointers as to which is the best. The first approach is very small, but is kinda hardwired and gets really cluttery with many options. The second one takes 3 times as much code, but is more dynamic and easy to see what it does. /* Approach #1 * Note that this one...
29
4392
by: keredil | last post by:
Hi, Will the memory allocated by malloc get released when program exits? I guess it will since when the program exits, the OS will free all the memory (global, stack, heap) used by this process. Is it correct?
6
2783
by: tigrfire | last post by:
I've been working on a program to try and play a game of Craps, based on a version I found elsewhere - I didn't code the original, but I added a few things such as a balance and wager system. I'm having trouble doing it all without using global variables though, so I have another post in this group about local variable usage and how to pass it, but just when I thought I'd got it, my program has a segmentation fault. I'm not exactly sure...
15
1887
by: ianweise | last post by:
hello, before i post my code for this, is there anyone out there at this moment? no sense in posting if no one is out there to read and answer it =P
66
3670
by: prady | last post by:
hi all, could any one solve the following C program. If any one knows the answer please post it Ques: A C function that will print 1 to N one per each line on the stdout , where N is a int parameter to the function. The function should not
16
1657
by: Ed Bitzer | last post by:
Trying to send groups of email with program using System.Net.Mail. I do not clear MailMessage but repeatedly loop changing only the Bcc entries. Works fine if all addresses are valid. As a simple test I have attempted to send a valid address, then an invalid address which my ISP (Comcast) will reject immediately as "Not our customer". I catch the exception, display and then continue looping to send several additional valid. The balance...
5
2494
by: mbewers1 | last post by:
I have a problem with this piece of code, which loads a splash screen and keeps it open for 5 seconds before loading another form. It strangely seems to be repeatedly running a thread once the method has executed and showing an unlimited number of splash screens but no main form. I've tried inserting mb.Suspend() and mb.Abort() after requesting the ShowDialog() method to be run for my main form, Form1. How can I stop the thread from...
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8905
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7743
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.