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.T imer(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.Inv okeRequired Then
Me.frmDates.Inv oke(New HideDateForm(Ad dressOf ProcHideDateFor m))
Else
Me.frmDates.Hid e()
End If
when it has to show
If Me.frmDates.Inv okeRequired Then
Me.frmDates.Inv oke(New ShowDateForm(Ad dressOf ProcShowDateFor m))
Else
Me.frmDates.Sho w()
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 ProcShowDateFor m()
Me.frmDates.Sho w()
End Sub
Public Sub ProcHideDateFor m()
Me.frmDates.Hid e()
End Sub
Public Sub ProcSendDatesTo Form(ByVal currentDates As List(Of DateTime))
Me.frmDates.Las tDates = currentDates
End Sub
and the form code
=============== ===========
Imports System.Text.Reg ularExpressions
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.Beg inUpdate()
Me.lstDates.Ite ms.Clear()
For Each d As DateTime In LastDates
Me.lstDates.Ite ms.Add(d.ToShor tDateString)
Next
Me.lstDates.End Update()
End Set
End Property
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeCompo nent()
' Add any initialization after the InitializeCompo nent() call.
End Sub
Protected Overrides Sub OnClosing(ByVal e As
System.Componen tModel.CancelEv entArgs)
e.Cancel = True
MyBase.OnClosin g(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.T imer(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.Inv okeRequired Then
Me.frmDates.Inv oke(New HideDateForm(Ad dressOf ProcHideDateFor m))
Else
Me.frmDates.Hid e()
End If
when it has to show
If Me.frmDates.Inv okeRequired Then
Me.frmDates.Inv oke(New ShowDateForm(Ad dressOf ProcShowDateFor m))
Else
Me.frmDates.Sho w()
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 ProcShowDateFor m()
Me.frmDates.Sho w()
End Sub
Public Sub ProcHideDateFor m()
Me.frmDates.Hid e()
End Sub
Public Sub ProcSendDatesTo Form(ByVal currentDates As List(Of DateTime))
Me.frmDates.Las tDates = currentDates
End Sub
and the form code
=============== ===========
Imports System.Text.Reg ularExpressions
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.Beg inUpdate()
Me.lstDates.Ite ms.Clear()
For Each d As DateTime In LastDates
Me.lstDates.Ite ms.Add(d.ToShor tDateString)
Next
Me.lstDates.End Update()
End Set
End Property
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeCompo nent()
' Add any initialization after the InitializeCompo nent() call.
End Sub
Protected Overrides Sub OnClosing(ByVal e As
System.Componen tModel.CancelEv entArgs)
e.Cancel = True
MyBase.OnClosin g(e)
Me.Hide()
End Sub
End Class
if anyone could PLEASE help me with whats going on i'd really appriciate it,
thanks!
Comment