Hi All,
I have a simple application that allows users to clock in and out and stores
the data for use by the payroll department. It spends most of its life as a
tray icon and when the user clicks on it, a clock-in/out form is displayed.
My problem is this:
I've added a timer to the main module to allow the user to set a time to be
reminded that they should clock back in/out. The timer works great (i.e. if
it's set to remind you at 5pm, it reminds you at 5pm), but when the elapsed
event fires and the clock-in/out form is displayed, the form elements don't
repaint themselves (it's just a frame with no components) and if you click
anywhere in the form, you get the windows error message that "the application
has stopped responding."
Here's the weird thing: The sub that I use to display the form after the
timer elapses is the same sub that I call when the user right-clicks the tray
icon and selects "Display Timeclock Form" and it works like a charm. I can
open and close the form all day long with the tray icon context menu, but
when I use the timer to display the form, it freezes.
Here's what I've got... simplified. Any insights would be greatly
appreciated!
Thanks!
Mike E.
Sub main()
reminderTimer = New Timer
reminderTimer.AutoReset = False
frmMain = New frmTimeTracker
'setup context menu
cMenu.MenuItems.Add("Open Time Tracker", AddressOf cMenu_Click)
cMenu.MenuItems.Add("Set / Reset Reminder Time", AddressOf
cMenu_Click)
cMenu.MenuItems.Add("Exit Time Tracker", AddressOf cMenu_Click)
'create tray icon
trayIcon.Text = Time Tracker"
trayIcon.Icon = frmMain.Icon
trayIcon.Visible = True
trayIcon.ContextMenu = cMenu
AddHandler reminderTimer.Elapsed, AddressOf OnTimerElapsed
Application.Run()
End Sub
Public Sub OnTimerElapsed(ByVal source As Object, ByVal e As
ElapsedEventArgs)
bReminderSet = False
reminderTimer.Enabled = False
reminderTimer.Close()
ShowTimecardForm()
End Sub
Private Sub ShowTimecardForm()
If (frmMain Is Nothing OrElse frmMain.IsDisposed) Then
frmMain = New frmTimeTracker
End If
frmMain.Show()
frmMain.txtPassword.Focus()
Application.DoEvents()
End Sub 7 2656
It sounds like a threading issue. You really can't tell becuase you didn't
post the suspect code block. Is the timer handler in a different thread than
the displayed form? Did you use a delegate? I'm just guessing...
"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message
news:E7**********************************@microsof t.com... Hi All,
I have a simple application that allows users to clock in and out and stores the data for use by the payroll department. It spends most of its life as a tray icon and when the user clicks on it, a clock-in/out form is displayed. My problem is this:
I've added a timer to the main module to allow the user to set a time to be reminded that they should clock back in/out. The timer works great (i.e. if it's set to remind you at 5pm, it reminds you at 5pm), but when the elapsed event fires and the clock-in/out form is displayed, the form elements don't repaint themselves (it's just a frame with no components) and if you click anywhere in the form, you get the windows error message that "the application has stopped responding."
Here's the weird thing: The sub that I use to display the form after the timer elapses is the same sub that I call when the user right-clicks the tray icon and selects "Display Timeclock Form" and it works like a charm. I can open and close the form all day long with the tray icon context menu, but when I use the timer to display the form, it freezes.
Here's what I've got... simplified. Any insights would be greatly appreciated!
Thanks! Mike E.
Sub main()
reminderTimer = New Timer reminderTimer.AutoReset = False
frmMain = New frmTimeTracker
'setup context menu cMenu.MenuItems.Add("Open Time Tracker", AddressOf cMenu_Click) cMenu.MenuItems.Add("Set / Reset Reminder Time", AddressOf cMenu_Click) cMenu.MenuItems.Add("Exit Time Tracker", AddressOf cMenu_Click)
'create tray icon trayIcon.Text = Time Tracker" trayIcon.Icon = frmMain.Icon trayIcon.Visible = True trayIcon.ContextMenu = cMenu
AddHandler reminderTimer.Elapsed, AddressOf OnTimerElapsed
Application.Run()
End Sub
Public Sub OnTimerElapsed(ByVal source As Object, ByVal e As ElapsedEventArgs) bReminderSet = False reminderTimer.Enabled = False reminderTimer.Close() ShowTimecardForm()
End Sub
Private Sub ShowTimecardForm() If (frmMain Is Nothing OrElse frmMain.IsDisposed) Then frmMain = New frmTimeTracker End If frmMain.Show() frmMain.txtPassword.Focus() Application.DoEvents() End Sub
Try this:
Application.Run(frmMain)
"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.com... Hi Jared,
I didn't set up an explicit thread for the timer, as I was just using Application.run to control the app. The timer handler is the OnTimerElapse method in the main module. Here's the rest of the code from the main module- hopefully it will help:
Private Sub trayIcon_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles trayIcon.DoubleClick ShowTimecardForm() End Sub
Private Sub cMenu_Click(ByVal sender As Object, ByVal e As EventArgs) Try Dim mi As MenuItem = DirectCast(sender, MenuItem) Select Case (mi.Text) Case "Open Time Tracker" ShowTimecardForm() Case "Set / Reset Reminder Time" PromptReminder() Case "Exit Time Tracker" Application.Exit() End Select Catch ice As InvalidCastException ErrorMessageToFile("Error in cMenu_Click: " + vbCrLf + ice.ToString) End Try
End Sub
Public Sub PromptReminder() Dim Reminder As ReminderFrm = New ReminderFrm
reminderTimer.Enabled = False
Reminder.ShowDialog() If (Reminder.DialogResult = DialogResult.OK) Then ReminderTime = Reminder.cboTimes.Text.ToString() Dim ts As TimeSpan ts = Date.Parse(ReminderTime).Subtract(Now) If (ts.TotalMilliseconds < 1) Then Exit Sub End If reminderTimer.Interval = ts.TotalMilliseconds bReminderSet = True reminderTimer.Enabled = True Else 'reminder cancelled End If End Sub
"Jared" wrote:
It sounds like a threading issue. You really can't tell becuase you didn't post the suspect code block. Is the timer handler in a different thread than the displayed form? Did you use a delegate? I'm just guessing...
"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message news:E7**********************************@microsof t.com... > Hi All, > > I have a simple application that allows users to clock in and out and > stores > the data for use by the payroll department. It spends most of its life > as > a > tray icon and when the user clicks on it, a clock-in/out form is > displayed. > My problem is this: > > I've added a timer to the main module to allow the user to set a time > to > be > reminded that they should clock back in/out. The timer works great > (i.e. > if > it's set to remind you at 5pm, it reminds you at 5pm), but when the > elapsed > event fires and the clock-in/out form is displayed, the form elements > don't > repaint themselves (it's just a frame with no components) and if you > click > anywhere in the form, you get the windows error message that "the > application > has stopped responding." > > Here's the weird thing: The sub that I use to display the form after > the > timer elapses is the same sub that I call when the user right-clicks > the > tray > icon and selects "Display Timeclock Form" and it works like a charm. I > can > open and close the form all day long with the tray icon context menu, > but > when I use the timer to display the form, it freezes. > > Here's what I've got... simplified. Any insights would be greatly > appreciated! > > Thanks! > Mike E. > > Sub main() > > reminderTimer = New Timer > reminderTimer.AutoReset = False > > frmMain = New frmTimeTracker > > 'setup context menu > cMenu.MenuItems.Add("Open Time Tracker", AddressOf cMenu_Click) > cMenu.MenuItems.Add("Set / Reset Reminder Time", AddressOf > cMenu_Click) > cMenu.MenuItems.Add("Exit Time Tracker", AddressOf cMenu_Click) > > 'create tray icon > trayIcon.Text = Time Tracker" > trayIcon.Icon = frmMain.Icon > trayIcon.Visible = True > trayIcon.ContextMenu = cMenu > > AddHandler reminderTimer.Elapsed, AddressOf OnTimerElapsed > > Application.Run() > > End Sub > > > Public Sub OnTimerElapsed(ByVal source As Object, ByVal e As > ElapsedEventArgs) > bReminderSet = False > reminderTimer.Enabled = False > reminderTimer.Close() > ShowTimecardForm() > > End Sub > > Private Sub ShowTimecardForm() > If (frmMain Is Nothing OrElse frmMain.IsDisposed) Then > frmMain = New frmTimeTracker > End If > frmMain.Show() > frmMain.txtPassword.Focus() > Application.DoEvents() > End Sub > >
I don't see how that would make a difference (could be my inexperience
talking), the documentation states that application.run will start a message
loop on the current thread, whereas application.run(frmMain) does the exact
same thing, except it initially displays a form.
The documentation on DoEvents also states:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfsystemwindowsformsapplicationclassdoeventstop ic.htm
CAUTION Calling this method can cause code to be re-entered if a message
raises an event.
I am assuming you placed the DoEvents in your code after you started having
problems in order to repaint your form.
You are also using a System.Timers.Timer and not a
System.Windows.Forms.Timer, read the overviews of each they define the
idiosyncrasies of each control. It seems like the system.timers.timer is
meant for multi-threaded apps and the system.windows.forms.timer is meant
for use in sta windows apps such as this one.
As a suggestion, I would dispose of my forms when done, and create a new
instance when the user requests it (if the overhead isn't too great, etc.)
especially if there may be several hours in between uses. I have a post in
microsoft.public.dotnet.languages.vb.controls titled "vb.net browser
refreshing" dated on 9.10.2004 that show an example of using a few api calls
to set the forms focus. It may come in handy when you are displaying your
reminders.
"Think_Fast" <nospam@haha> wrote in message
news:10*************@corp.supernews.com... Try this:
Application.Run(frmMain)
"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message news:69**********************************@microsof t.com... Hi Jared,
I didn't set up an explicit thread for the timer, as I was just using Application.run to control the app. The timer handler is the OnTimerElapse method in the main module. Here's the rest of the code from the main module- hopefully it will help:
Private Sub trayIcon_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles trayIcon.DoubleClick ShowTimecardForm() End Sub
Private Sub cMenu_Click(ByVal sender As Object, ByVal e As EventArgs) Try Dim mi As MenuItem = DirectCast(sender, MenuItem) Select Case (mi.Text) Case "Open Time Tracker" ShowTimecardForm() Case "Set / Reset Reminder Time" PromptReminder() Case "Exit Time Tracker" Application.Exit() End Select Catch ice As InvalidCastException ErrorMessageToFile("Error in cMenu_Click: " + vbCrLf + ice.ToString) End Try
End Sub
Public Sub PromptReminder() Dim Reminder As ReminderFrm = New ReminderFrm
reminderTimer.Enabled = False
Reminder.ShowDialog() If (Reminder.DialogResult = DialogResult.OK) Then ReminderTime = Reminder.cboTimes.Text.ToString() Dim ts As TimeSpan ts = Date.Parse(ReminderTime).Subtract(Now) If (ts.TotalMilliseconds < 1) Then Exit Sub End If reminderTimer.Interval = ts.TotalMilliseconds bReminderSet = True reminderTimer.Enabled = True Else 'reminder cancelled End If End Sub
"Jared" wrote:
It sounds like a threading issue. You really can't tell becuase you didn't post the suspect code block. Is the timer handler in a different thread than the displayed form? Did you use a delegate? I'm just guessing...
"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message news:E7**********************************@microsof t.com... > Hi All, > > I have a simple application that allows users to clock in and out and > stores > the data for use by the payroll department. It spends most of its > life as > a > tray icon and when the user clicks on it, a clock-in/out form is > displayed. > My problem is this: > > I've added a timer to the main module to allow the user to set a time > to > be > reminded that they should clock back in/out. The timer works great > (i.e. > if > it's set to remind you at 5pm, it reminds you at 5pm), but when the > elapsed > event fires and the clock-in/out form is displayed, the form elements > don't > repaint themselves (it's just a frame with no components) and if you > click > anywhere in the form, you get the windows error message that "the > application > has stopped responding." > > Here's the weird thing: The sub that I use to display the form after > the > timer elapses is the same sub that I call when the user right-clicks > the > tray > icon and selects "Display Timeclock Form" and it works like a charm. > I > can > open and close the form all day long with the tray icon context menu, > but > when I use the timer to display the form, it freezes. > > Here's what I've got... simplified. Any insights would be greatly > appreciated! > > Thanks! > Mike E. > > Sub main() > > reminderTimer = New Timer > reminderTimer.AutoReset = False > > frmMain = New frmTimeTracker > > 'setup context menu > cMenu.MenuItems.Add("Open Time Tracker", AddressOf cMenu_Click) > cMenu.MenuItems.Add("Set / Reset Reminder Time", AddressOf > cMenu_Click) > cMenu.MenuItems.Add("Exit Time Tracker", AddressOf cMenu_Click) > > 'create tray icon > trayIcon.Text = Time Tracker" > trayIcon.Icon = frmMain.Icon > trayIcon.Visible = True > trayIcon.ContextMenu = cMenu > > AddHandler reminderTimer.Elapsed, AddressOf OnTimerElapsed > > Application.Run() > > End Sub > > > Public Sub OnTimerElapsed(ByVal source As Object, ByVal e As > ElapsedEventArgs) > bReminderSet = False > reminderTimer.Enabled = False > reminderTimer.Close() > ShowTimecardForm() > > End Sub > > Private Sub ShowTimecardForm() > If (frmMain Is Nothing OrElse frmMain.IsDisposed) Then > frmMain = New frmTimeTracker > End If > frmMain.Show() > frmMain.txtPassword.Focus() > Application.DoEvents() > End Sub > >
Forgot a couple of things. First make the form invisible.
frmMain.Visible=False
Application.Run(frmMain)
And put this in your closing event of your form otherwise the application
will terminate
Private Sub frmTimeTracker_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Me.Visible = False
e.Cancel = True
End Sub
"Think_Fast" <nospam@haha> wrote in message
news:10*************@corp.supernews.com... Try this:
Application.Run(frmMain)
"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message news:69**********************************@microsof t.com... Hi Jared,
I didn't set up an explicit thread for the timer, as I was just using Application.run to control the app. The timer handler is the OnTimerElapse method in the main module. Here's the rest of the code from the main module- hopefully it will help:
Private Sub trayIcon_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles trayIcon.DoubleClick ShowTimecardForm() End Sub
Private Sub cMenu_Click(ByVal sender As Object, ByVal e As EventArgs) Try Dim mi As MenuItem = DirectCast(sender, MenuItem) Select Case (mi.Text) Case "Open Time Tracker" ShowTimecardForm() Case "Set / Reset Reminder Time" PromptReminder() Case "Exit Time Tracker" Application.Exit() End Select Catch ice As InvalidCastException ErrorMessageToFile("Error in cMenu_Click: " + vbCrLf + ice.ToString) End Try
End Sub
Public Sub PromptReminder() Dim Reminder As ReminderFrm = New ReminderFrm
reminderTimer.Enabled = False
Reminder.ShowDialog() If (Reminder.DialogResult = DialogResult.OK) Then ReminderTime = Reminder.cboTimes.Text.ToString() Dim ts As TimeSpan ts = Date.Parse(ReminderTime).Subtract(Now) If (ts.TotalMilliseconds < 1) Then Exit Sub End If reminderTimer.Interval = ts.TotalMilliseconds bReminderSet = True reminderTimer.Enabled = True Else 'reminder cancelled End If End Sub
"Jared" wrote:
It sounds like a threading issue. You really can't tell becuase you didn't post the suspect code block. Is the timer handler in a different thread than the displayed form? Did you use a delegate? I'm just guessing...
"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message news:E7**********************************@microsof t.com... > Hi All, > > I have a simple application that allows users to clock in and out and > stores > the data for use by the payroll department. It spends most of its > life as > a > tray icon and when the user clicks on it, a clock-in/out form is > displayed. > My problem is this: > > I've added a timer to the main module to allow the user to set a time > to > be > reminded that they should clock back in/out. The timer works great > (i.e. > if > it's set to remind you at 5pm, it reminds you at 5pm), but when the > elapsed > event fires and the clock-in/out form is displayed, the form elements > don't > repaint themselves (it's just a frame with no components) and if you > click > anywhere in the form, you get the windows error message that "the > application > has stopped responding." > > Here's the weird thing: The sub that I use to display the form after > the > timer elapses is the same sub that I call when the user right-clicks > the > tray > icon and selects "Display Timeclock Form" and it works like a charm. > I > can > open and close the form all day long with the tray icon context menu, > but > when I use the timer to display the form, it freezes. > > Here's what I've got... simplified. Any insights would be greatly > appreciated! > > Thanks! > Mike E. > > Sub main() > > reminderTimer = New Timer > reminderTimer.AutoReset = False > > frmMain = New frmTimeTracker > > 'setup context menu > cMenu.MenuItems.Add("Open Time Tracker", AddressOf cMenu_Click) > cMenu.MenuItems.Add("Set / Reset Reminder Time", AddressOf > cMenu_Click) > cMenu.MenuItems.Add("Exit Time Tracker", AddressOf cMenu_Click) > > 'create tray icon > trayIcon.Text = Time Tracker" > trayIcon.Icon = frmMain.Icon > trayIcon.Visible = True > trayIcon.ContextMenu = cMenu > > AddHandler reminderTimer.Elapsed, AddressOf OnTimerElapsed > > Application.Run() > > End Sub > > > Public Sub OnTimerElapsed(ByVal source As Object, ByVal e As > ElapsedEventArgs) > bReminderSet = False > reminderTimer.Enabled = False > reminderTimer.Close() > ShowTimecardForm() > > End Sub > > Private Sub ShowTimecardForm() > If (frmMain Is Nothing OrElse frmMain.IsDisposed) Then > frmMain = New frmTimeTracker > End If > frmMain.Show() > frmMain.txtPassword.Focus() > Application.DoEvents() > End Sub > >
Mike,
When I see it right in your code, than you are creating everytime a new form
from the same class, try to work with visible true and false or something
like that and use the object you are in.
You can not instance an object as new and delete it in the same time the one
which is instancing it.
When I see it right you do now something as
frmmain
new frmmain
new frmmain
new frmmain
new frmmain
I hope this helps?
Cor
Hi Jared,
I didn't set up an explicit thread for the timer, as I was just using
Application.run to control the app. The timer handler is the OnTimerElapse
method in the main module. Here's the rest of the code from the main module-
hopefully it will help:
Private Sub trayIcon_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles trayIcon.DoubleClick
ShowTimecardForm()
End Sub
Private Sub cMenu_Click(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim mi As MenuItem = DirectCast(sender, MenuItem)
Select Case (mi.Text)
Case "Open Time Tracker"
ShowTimecardForm()
Case "Set / Reset Reminder Time"
PromptReminder()
Case "Exit Time Tracker"
Application.Exit()
End Select
Catch ice As InvalidCastException
ErrorMessageToFile("Error in cMenu_Click: " + vbCrLf +
ice.ToString)
End Try
End Sub
Public Sub PromptReminder()
Dim Reminder As ReminderFrm = New ReminderFrm
reminderTimer.Enabled = False
Reminder.ShowDialog()
If (Reminder.DialogResult = DialogResult.OK) Then
ReminderTime = Reminder.cboTimes.Text.ToString()
Dim ts As TimeSpan
ts = Date.Parse(ReminderTime).Subtract(Now)
If (ts.TotalMilliseconds < 1) Then
Exit Sub
End If
reminderTimer.Interval = ts.TotalMilliseconds
bReminderSet = True
reminderTimer.Enabled = True
Else
'reminder cancelled
End If
End Sub
"Jared" wrote: It sounds like a threading issue. You really can't tell becuase you didn't post the suspect code block. Is the timer handler in a different thread than the displayed form? Did you use a delegate? I'm just guessing...
"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message news:E7**********************************@microsof t.com... Hi All,
I have a simple application that allows users to clock in and out and stores the data for use by the payroll department. It spends most of its life as a tray icon and when the user clicks on it, a clock-in/out form is displayed. My problem is this:
I've added a timer to the main module to allow the user to set a time to be reminded that they should clock back in/out. The timer works great (i.e. if it's set to remind you at 5pm, it reminds you at 5pm), but when the elapsed event fires and the clock-in/out form is displayed, the form elements don't repaint themselves (it's just a frame with no components) and if you click anywhere in the form, you get the windows error message that "the application has stopped responding."
Here's the weird thing: The sub that I use to display the form after the timer elapses is the same sub that I call when the user right-clicks the tray icon and selects "Display Timeclock Form" and it works like a charm. I can open and close the form all day long with the tray icon context menu, but when I use the timer to display the form, it freezes.
Here's what I've got... simplified. Any insights would be greatly appreciated!
Thanks! Mike E.
Sub main()
reminderTimer = New Timer reminderTimer.AutoReset = False
frmMain = New frmTimeTracker
'setup context menu cMenu.MenuItems.Add("Open Time Tracker", AddressOf cMenu_Click) cMenu.MenuItems.Add("Set / Reset Reminder Time", AddressOf cMenu_Click) cMenu.MenuItems.Add("Exit Time Tracker", AddressOf cMenu_Click)
'create tray icon trayIcon.Text = Time Tracker" trayIcon.Icon = frmMain.Icon trayIcon.Visible = True trayIcon.ContextMenu = cMenu
AddHandler reminderTimer.Elapsed, AddressOf OnTimerElapsed
Application.Run()
End Sub
Public Sub OnTimerElapsed(ByVal source As Object, ByVal e As ElapsedEventArgs) bReminderSet = False reminderTimer.Enabled = False reminderTimer.Close() ShowTimecardForm()
End Sub
Private Sub ShowTimecardForm() If (frmMain Is Nothing OrElse frmMain.IsDisposed) Then frmMain = New frmTimeTracker End If frmMain.Show() frmMain.txtPassword.Focus() Application.DoEvents() End Sub
Hi Jared,
I didn't set up an explicit thread for the timer, as I was just using
Application.run to control the app. The timer handler is the OnTimerElapse
method in the main module. Here's the rest of the code from the main module-
hopefully it will help:
Private Sub trayIcon_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles trayIcon.DoubleClick
ShowTimecardForm()
End Sub
Private Sub cMenu_Click(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim mi As MenuItem = DirectCast(sender, MenuItem)
Select Case (mi.Text)
Case "Open Time Tracker"
ShowTimecardForm()
Case "Set / Reset Reminder Time"
PromptReminder()
Case "Exit Time Tracker"
Application.Exit()
End Select
Catch ice As InvalidCastException
ErrorMessageToFile("Error in cMenu_Click: " + vbCrLf +
ice.ToString)
End Try
End Sub
Public Sub PromptReminder()
Dim Reminder As ReminderFrm = New ReminderFrm
reminderTimer.Enabled = False
Reminder.ShowDialog()
If (Reminder.DialogResult = DialogResult.OK) Then
ReminderTime = Reminder.cboTimes.Text.ToString()
Dim ts As TimeSpan
ts = Date.Parse(ReminderTime).Subtract(Now)
If (ts.TotalMilliseconds < 1) Then
Exit Sub
End If
reminderTimer.Interval = ts.TotalMilliseconds
bReminderSet = True
reminderTimer.Enabled = True
Else
'reminder cancelled
End If
End Sub
"Jared" wrote: It sounds like a threading issue. You really can't tell becuase you didn't post the suspect code block. Is the timer handler in a different thread than the displayed form? Did you use a delegate? I'm just guessing...
"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message news:E7**********************************@microsof t.com... Hi All,
I have a simple application that allows users to clock in and out and stores the data for use by the payroll department. It spends most of its life as a tray icon and when the user clicks on it, a clock-in/out form is displayed. My problem is this:
I've added a timer to the main module to allow the user to set a time to be reminded that they should clock back in/out. The timer works great (i.e. if it's set to remind you at 5pm, it reminds you at 5pm), but when the elapsed event fires and the clock-in/out form is displayed, the form elements don't repaint themselves (it's just a frame with no components) and if you click anywhere in the form, you get the windows error message that "the application has stopped responding."
Here's the weird thing: The sub that I use to display the form after the timer elapses is the same sub that I call when the user right-clicks the tray icon and selects "Display Timeclock Form" and it works like a charm. I can open and close the form all day long with the tray icon context menu, but when I use the timer to display the form, it freezes.
Here's what I've got... simplified. Any insights would be greatly appreciated!
Thanks! Mike E.
Sub main()
reminderTimer = New Timer reminderTimer.AutoReset = False
frmMain = New frmTimeTracker
'setup context menu cMenu.MenuItems.Add("Open Time Tracker", AddressOf cMenu_Click) cMenu.MenuItems.Add("Set / Reset Reminder Time", AddressOf cMenu_Click) cMenu.MenuItems.Add("Exit Time Tracker", AddressOf cMenu_Click)
'create tray icon trayIcon.Text = Time Tracker" trayIcon.Icon = frmMain.Icon trayIcon.Visible = True trayIcon.ContextMenu = cMenu
AddHandler reminderTimer.Elapsed, AddressOf OnTimerElapsed
Application.Run()
End Sub
Public Sub OnTimerElapsed(ByVal source As Object, ByVal e As ElapsedEventArgs) bReminderSet = False reminderTimer.Enabled = False reminderTimer.Close() ShowTimecardForm()
End Sub
Private Sub ShowTimecardForm() If (frmMain Is Nothing OrElse frmMain.IsDisposed) Then frmMain = New frmTimeTracker End If frmMain.Show() frmMain.txtPassword.Focus() Application.DoEvents() End Sub
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: rhaley |
last post by:
ugh. Okay, I need to figure out the number of milliseconds between
DateTime.Now and the end of the day so that I can make changes based on
the date roll-over. I need to implement a Timer so that I...
|
by: Besta |
last post by:
Hello all,
I am having trouble creating a windows service with a timer.
Everything seems to go ok but the elapsed event does not fire.Can
anyone shed any light on this, may be something simple as...
|
by: Philip Wagenaar |
last post by:
Hello,
I am using a timer object in my Windows Forms Application. Does the code in
..elapsed event run in a diffrent thread? If the interval is set to 10
milliseconds and the time to execute the...
|
by: Liverpool fan |
last post by:
I have a windows application written using VB .NET that encompasses a
countdown timer modal dialog. The timer is a System.Timers.Timer with
an interval of 1 second. AutoReset is not set so accepts...
|
by: martin1 |
last post by:
All,
is there window form refresh property? I try to set up window form refresh
per minute. Thanks
|
by: Gina_Marano |
last post by:
I have created an array of timers (1-n). At first I just created
windows form timers but I read that system timers are better for
background work. The timers will just be monitoring different...
|
by: Tony Gravagno |
last post by:
I have a class that instantiates two Timer objects that fire at
different intervals. My class can be instantiated within a Windows
Form or from a Windows Service. Actions performed by one of the...
|
by: igor |
last post by:
I have recently discovered that the system.Timers.Timer from.Net
Framework v1.1 is not reliable when used on Windows 2003 server. When
incorporated into a Windows Service, the timer_elapsed event...
|
by: Boki |
last post by:
Hi All,
I have a timer, if my data queue Q has data, the timer should start
work, if there is no data in Q, the timer should stop.
However, there is an event can fire timer to start.
Should I...
|
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
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |