Help with timer(s)?

  • Thread starter Thread starter sherifffruitfly
  • Start date Start date
S

sherifffruitfly

I admit it - I don't have the foggiest notion how to use the timer
class(es) in c# - i've looked at tutorials, and it's still completely
unintutive to me. Anyone nice enough to get me started on the following
problem would be my favorite person in the world!

A file is made available on a network drive sometime after noon, and I
want to copy it. I want the application to wait until 12 noon, check
for the file, if it's there, copy it, if not wait check again every 15
minutes. At 4pm, if the file still hasn't been copied, email a
particular person.

I've written a "manual" version of the above app, requiring the user to
click a button to check for/copy the file. It's the timer stuff that
I'm clueless on.

Any help would be appreciated...

cdj
 
Hi,

At the end what kind of app this will run in?

Working with timers is super easy, all you have to do is set the interval
you want and the method you want to be invoked.

When the method is execute you do your work and you can modify the timer if
needed.

IIRC one of the timers need to either be restarted everytime or need to set
a property in order to do so.


In any case post some code and will figure out why its not working
 
Ignacio said:
Hi,

At the end what kind of app this will run in?

I've got it running in my system tray now... Offhand, I see no reason
to move it from there... I figure on just keeping it running in the
tray all the time, and changing the tray icon upon a successful copy.
That's all straightforward, and is working now.

It's just time timer stuff specifically that I'm clueless on.
Working with timers is super easy, all you have to do is set the interval
you want and the method you want to be invoked.
In any case post some code and will figure out why its not working

I don't have any timer code yet - that was the point of my request -
lol.

Here's the download routine as it currently stands (it's just the event
handler for the button click):

private void downloadRates(string sourceFile, string destinationFile)
{
WebClient client = new WebClient();
client.Credentials = CredentialCache.DefaultCredentials;

try
{
client.DownloadFile(sourceFile, destinationFile);
}
catch(Exception e)
{
MessageBox.Show(
e.Message+"\n\nException source: "+e.Source+"\n\n"+e.ToString(),
"failed to download Dow Jones prices");
}
}

I'm basically looking to put this on a timer, like I mentioned.

Thanks for replying - I suspect I'll just have to go spend some more
time with what-seems-to-me-unintelligible timer tutorial sites...


Thanks again,

cdj
 
Hi,
I'm basically looking to put this on a timer, like I mentioned.

Thanks for replying - I suspect I'll just have to go spend some more
time with what-seems-to-me-unintelligible timer tutorial sites...

Yep, that would be a good idea

Just add a timer fmro the toolbox, set its property and double click the
icon to create the method. then all you have to do is call your download
routine from there
 
Back
Top