The application crashes when a form appears
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts
Page 1 of 1
I made a code which is able to save in two lists results in real time from a web page, so far everything has worked very well, then I decided to add an additional feature and that is to show the results that have changed (ie when a team scored a goal), in a form of notifications. I then made an additional form called "notifiche" and I implemented the procedure as follows:
Code: Select all
all the code works very well, the results that have changed are shown, the problem lies in the form of notification. In particular when the notification should appear the application crashes. I can't explain why because if I open the form "notifiche" for example by pressing a button with "notifiche.show()", this shows no problem opening.Dim keepLogging As Boolean = True
If popup = True Then 'this variable is valorized when the form's minimized
For Each abc As Country_Data In lista
For Each xyz As Country_Data In vecchia_lista
If abc.casa = xyz.casa And abc.ospite = xyz.ospite Then
If abc.result <> xyz.result Then
'function that show the notification
show_popup(abc.casa, abc.ospite, abc.minuto, abc.result)
keepLogging = False
Exit For
End If
End If
Next
If (Not keepLogging) Then Exit For
Next
End If
Code: Select all
This is the class of notifiche form:Function show_popup(casa, ospite, risultato, minuto)
notifiche.Show()
notifiche.MetroLabel1.Text = casa
notifiche.MetroLabel2.Text = risultato
notifiche.MetroLabel3.Text = ospite
notifiche.MetroLabel4.Text = minuto
End Function
Code: Select all
I also tried with adding exceptions, but there isn't exception generated. I tried with a simple form without anything in the class and the problem is the same. I think that is a problem of the loop at this point.Public Class notifiche
Dim i As Integer = 0
Private Sub notifiche_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Location = New Point( _
Screen.PrimaryScreen.Bounds.Width - 400, _
Screen.PrimaryScreen.Bounds.Height)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Me.Opacity = 0 Then Me.Close()
If i = 500 Then
Me.Opacity -= 0.02
End If
If Not Me.Location.Y = Screen.PrimaryScreen.WorkingArea.Height - 200 Then
Me.Location = New Point(Me.Location.X, Me.Location.Y - 2)
End If
If Not i = 500 Then i += 1
End Sub
End Class
I'm in the empire business.
Hmm.. Your code is working fine on my setup..
Take look at your passed params in show_popup and what params are you passing. Maybe there is a typo.
Next try to place breakpoint at
Take look at your passed params in show_popup and what params are you passing. Maybe there is a typo.
Next try to place breakpoint at
Code: Select all
and go step by step to find where your app crashes.If abc.result <> xyz.result Then
I solve put a BackgroundWorker instead of the thread.
I used the thread and seems that the need create a delegate of main thread for run a new form to another thread.
I used the thread and seems that the need create a delegate of main thread for run a new form to another thread.
I'm in the empire business.
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023