S
Smokey Grindle
I have my entire program in a Sub Main class and it runs as a notify tray
icon 99% of the time... inside the program there is a timer whihc is
declared like this
Dim WithEvents MyTimer As New System.Timers.Timer(20000)
the timer checks every 20 seconds a website to pull information from... if a
date is found on the page it looks at, it makes a list of dates and places
them into a date collection declared like this
Dim CurrentDates As New List(Of DateTime)
I also have a "dates form" that will pop up on screen if a date is found.
This is a form that never closes it is only shown and hidden from the
user... now every 20 seconds when the timer "ticks" my web task happens
(cant post code, because of information that is in it) this works perfecly
fine! but when we included the form in the mix, the problems started... the
web part works correctly, but the form is lagging... it will pop up, and
take forever to show the list of dates in its listbox.. then it shows "not
responding" in the titlebar after a second, then after a couple more seconds
it redraws correctly, then it lags again... at one point i was getting
"illegal cross thread.." something or other i forget exceptions when I
opened the form... I tried doing this with delegates but no real changes
that I noticed... here is how I am calling the forms now
when it has to hide
If Me.frmDates.InvokeRequired Then
Me.frmDates.Invoke(New HideDateForm(AddressOf ProcHideDateForm))
Else
Me.frmDates.Hide()
End If
when it has to show
If Me.frmDates.InvokeRequired Then
Me.frmDates.Invoke(New ShowDateForm(AddressOf ProcShowDateForm))
Else
Me.frmDates.Show()
End If
the delegate declerations
Public Delegate Sub ShowDateForm()
Public Delegate Sub HideDateForm()
Public Delegate Sub SendDatesToForm(ByVal currentDates As List(Of DateTime))
Public Sub ProcShowDateForm()
Me.frmDates.Show()
End Sub
Public Sub ProcHideDateForm()
Me.frmDates.Hide()
End Sub
Public Sub ProcSendDatesToForm(ByVal currentDates As List(Of DateTime))
Me.frmDates.LastDates = currentDates
End Sub
and the form code
==========================
Imports System.Text.RegularExpressions
Public Class frmDates
Private m_lastHTML As New List(Of DateTime)
''' <summary>
''' Last HTML response
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property LastDates() As List(Of DateTime)
Get
Return m_lastHTML
End Get
Set(ByVal value As List(Of DateTime))
m_lastHTML = value
Me.lstDates.BeginUpdate()
Me.lstDates.Items.Clear()
For Each d As DateTime In LastDates
Me.lstDates.Items.Add(d.ToShortDateString)
Next
Me.lstDates.EndUpdate()
End Set
End Property
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
Protected Overrides Sub OnClosing(ByVal e As
System.ComponentModel.CancelEventArgs)
e.Cancel = True
MyBase.OnClosing(e)
Me.Hide()
End Sub
End Class
if anyone could PLEASE help me with whats going on i'd really appriciate it,
thanks!
icon 99% of the time... inside the program there is a timer whihc is
declared like this
Dim WithEvents MyTimer As New System.Timers.Timer(20000)
the timer checks every 20 seconds a website to pull information from... if a
date is found on the page it looks at, it makes a list of dates and places
them into a date collection declared like this
Dim CurrentDates As New List(Of DateTime)
I also have a "dates form" that will pop up on screen if a date is found.
This is a form that never closes it is only shown and hidden from the
user... now every 20 seconds when the timer "ticks" my web task happens
(cant post code, because of information that is in it) this works perfecly
fine! but when we included the form in the mix, the problems started... the
web part works correctly, but the form is lagging... it will pop up, and
take forever to show the list of dates in its listbox.. then it shows "not
responding" in the titlebar after a second, then after a couple more seconds
it redraws correctly, then it lags again... at one point i was getting
"illegal cross thread.." something or other i forget exceptions when I
opened the form... I tried doing this with delegates but no real changes
that I noticed... here is how I am calling the forms now
when it has to hide
If Me.frmDates.InvokeRequired Then
Me.frmDates.Invoke(New HideDateForm(AddressOf ProcHideDateForm))
Else
Me.frmDates.Hide()
End If
when it has to show
If Me.frmDates.InvokeRequired Then
Me.frmDates.Invoke(New ShowDateForm(AddressOf ProcShowDateForm))
Else
Me.frmDates.Show()
End If
the delegate declerations
Public Delegate Sub ShowDateForm()
Public Delegate Sub HideDateForm()
Public Delegate Sub SendDatesToForm(ByVal currentDates As List(Of DateTime))
Public Sub ProcShowDateForm()
Me.frmDates.Show()
End Sub
Public Sub ProcHideDateForm()
Me.frmDates.Hide()
End Sub
Public Sub ProcSendDatesToForm(ByVal currentDates As List(Of DateTime))
Me.frmDates.LastDates = currentDates
End Sub
and the form code
==========================
Imports System.Text.RegularExpressions
Public Class frmDates
Private m_lastHTML As New List(Of DateTime)
''' <summary>
''' Last HTML response
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property LastDates() As List(Of DateTime)
Get
Return m_lastHTML
End Get
Set(ByVal value As List(Of DateTime))
m_lastHTML = value
Me.lstDates.BeginUpdate()
Me.lstDates.Items.Clear()
For Each d As DateTime In LastDates
Me.lstDates.Items.Add(d.ToShortDateString)
Next
Me.lstDates.EndUpdate()
End Set
End Property
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
Protected Overrides Sub OnClosing(ByVal e As
System.ComponentModel.CancelEventArgs)
e.Cancel = True
MyBase.OnClosing(e)
Me.Hide()
End Sub
End Class
if anyone could PLEASE help me with whats going on i'd really appriciate it,
thanks!