I've got a timer which ticks every half a second. It calls a background process which renders text as icons and uses them for notification icons.
Public Shared DISCUS(9) As NotifyIcon
Private Sub BackgroundProcess2_DoWork() Handles BackgroundProcess2.DoWork
Try
For counter As Integer = 0 To My.Computer.FileSystem.Drives.Count - 1
Dim FontColor As Color
If Math.Round((this / that) * 100, decimals:=0) < 25 Then
FontColor = Settings1.Default.CriticalColor
ElseIf Math.Round((this / that) * 100, decimals:=0) >= 25 And Math.Round((actualsize / ofsize) * 100, decimals:=0) < 50 Then
FontColor = Settings1.Default.WarningColor
Else
FontColor = Settings1.Default.NominalColor
End If
Dim BackColor As Color = Color.Transparent
Dim FontName As String = Settings1.Default.InterfaceFont.Name
Dim FontSize As Integer = 9
Dim iHeight As Integer = 16
Dim iWidth As Integer = 16
Dim objBitmap As New Bitmap(iWidth, iHeight)
Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)
Dim objFont As New Font(FontName, FontSize)
Dim objPoint As New PointF(1, 0)
Dim objBrushForeColor As New SolidBrush(FontColor)
Dim objBrushBackColor As New SolidBrush(BackColor)
objGraphics.FillRectangle(objBrushBackColor, 0, 0, Width, Height)
objGraphics.DrawString(Text, objFont, objBrushForeColor, objPoint)
Dim img As Bitmap = objBitmap
Dim hIcon As IntPtr = img.GetHicon()
Dim icn As Icon = Icon.FromHandle(hIcon)
DISCUS(counter).Text = My.Computer.FileSystem.GetDriveInfo(My.Computer.FileSystem.Drives.Item(counter).ToString).VolumeLabel & vbCrLf & "Free space:" & vbCrLf & actualsize & stringvalue1 & " of " & ofsize & stringvalue2 & " (" & (Math.Round((this / that), decimals:=2) * 100) & "%)"
DISCUS(counter).BalloonTipText = Text
DISCUS(counter).Icon = icn
icn.Dispose()
DISCUS(counter).ContextMenuStrip = ContextMenuStrip1
Next
Catch ex as exception
My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Desktop & "\DT crash log.txt", "Log: " & My.Computer.Clock.LocalTime.Date.ToString & vbCrLf & o.ToString & vbCrLf & vbCrLf, True)
End Try
End Sub
Now for some reason, after a few minutes of the application being active, I get a JIT pop-up that doesn't render any text or buttons. Clicking on it causes the JIT debugger to crash, and I get the Windows "{App} has stopped responding." with error code CLR20R3. I'm not sure what this is all about, but I can provide any other details if needed. I've got everything nested in Try/Catch statements, all with code to write to a crash log but nothing gets written and I still get that error message.
Can anyone give me any pointers?