Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer control running in the background 1

Status
Not open for further replies.

steve1rm

Programmer
Aug 26, 2006
255
GB
Hello

VS 2005,

I am developing MDI application. The user would like to have an timer running in the back ground that will send e-mail every 5 times.

Sending the e-mails is not the problem, but how can I control the timer in the back ground.

On one of the mdi forms the user will select send e-mails (start timer) and on this same form the user can stop sending e-mails (stop timer).

Would a timer control in the main form be ok? If so, then the mdi form that controls the start and stop should be able to communicate this to the main form. If the form that starts and stops the timer is closed the timer should still run. The timer should run until the application is completely closed by the user.

Any suggestions or code examples would be most grateful,

Thanks,

Steve
 
You can pass the timer to the mdi childform, there's nice little FAQ (non exhaustive list) of ways to pass data between forms : faq796-5773
 
Drag'n'drop a Components.Timer onto MDI parent form, call it something useful, set the interval to 300000 (5min), set Enabled to False. Double click on the timer icon and put your email sending code (or call the function) in the event handler sub...

Then, on your child form button events, use something like:
Code:
'SendEmails_Click....
    Dim frm As MyMDIParent = Me.MdiParent

    If frm.EmailTimer.Enabled = False Then
        frm.EmailTimer.Start()
    End If

'StopEmails_Click....
    Dim frm As MyMDIParent = Me.MdiParent

    frm.EmailTimer.Stop()

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top