Wyko
Member
- Joined
- Jul 11, 2009
- Messages
- 5
- Programming Experience
- 5-10
This is a little app that sits in your task bar and check a website for the presence of a simple string. The string is either "ONLINE" or "OFFLINE". THe problem is that there seems to be a minor memory leak, since every once in a while (I suppose when the timer expires) the memory it takes up increases by a good bit. Any ideas on what's wrong?
VB.NET:
Public Class frmMain
Dim WithEvents nIcon As NotifyIcon
Dim WebB As WebBrowser
Dim WithEvents timer1 As Timer
Dim WithEvents timer2 As Timer
Dim AtLastCheck = False 'Turns true if server was on at last check
Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
nIcon.Visible = False
End Sub
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
nIcon = New NotifyIcon
timer1 = New Timer
timer2 = New Timer
Me.Visible = False
Me.ShowInTaskbar = False
WebB = New WebBrowser
WebB.Navigate("http://beta.leagueoflegends.com/server_status.php?raw")
timer1.Interval = 15000
timer2.Interval = 15000
timer2.Start()
nIcon.Icon = My.Resources.icon_small_disabled
nIcon.Text = "Loading Server Status"
nIcon.Visible = True
End Sub
Private Sub timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer1.Tick
WebB = New WebBrowser
WebB.Navigate("http://beta.leagueoflegends.com/server_status.php?raw")
timer2.Start()
timer1.Stop()
End Sub
Private Sub CheckServer()
If WebB.DocumentText.Equals("ONLINE") And AtLastCheck = False Then
nIcon.ShowBalloonTip(600000, "Server Online", "League of Legends Beta Server is now online!", ToolTipIcon.Info)
AtLastCheck = True
nIcon.Text = "Server Staus: Online"
My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Exclamation)
nIcon.Icon = My.Resources.icon_medium
ElseIf WebB.DocumentText.Equals("OFFLINE") Then
nIcon.Text = "Server Staus: Offline"
nIcon.Icon = My.Resources.icon_small_disabled
AtLastCheck = False
End If
WebB.Dispose()
End Sub
Private Sub nIcon_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles nIcon.DoubleClick
Dim msg As MsgBoxResult = MessageBox.Show("Do you want to exit Wyko's server status updater?", "Exit?", MessageBoxButtons.YesNo)
If msg = MsgBoxResult.Yes Then
nIcon.Visible = False
Application.Exit()
End If
End Sub
Private Sub timer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer2.Tick
CheckServer()
timer1.Start()
timer2.Stop()
End Sub
End Class