Hello,
I'm a student and for a project at school I'm working on a simple FXP client.
This client uses multithreading. I used the article of Russell Jones at devX, wich was a big help to me to understand, how this mechanism of passing parameters, etc... work. (http://www.devx.com/dotnet/Article/11358)
I was using VB.NET 2005 beta 1 and I got everything working fine. Because of the recent expiration of beta 1 I upgraded to beta 2 and I got serieus troubles with invoking controls on my main form.
I already have posted my troubles in different VB.NET forums but nobody seems to know an answer to my troubles. So I'm really stuck now, and I have to deliver my project to the teacher soon. So, I'm a bit desperate.
What do I do:
On my main form (class frmMain) I have a listview called lstvErrorMessages.
Because I have to connect to different FTP-servers at the same time (for Site to Site transfers) I use different threads to establish that.
Sometime it is impossible to connect (server down or something) and I wanna display an error message.
So in my main form's class I have:
On a different Class:Code:Public Class frmMain .... Delegate Sub AddToLstvDelegate(ByVal lstvListView As ListView, ByVal AddItem As String, ByVal ImageNumber As Integer, ByVal Color As Integer) Public Sub AddToLstv(ByVal lstvListView As ListView, ByVal AddItem As String, ByVal ImageNumber As Integer, ByVal Color As Integer) Dim listViewItem As New ListViewItem listViewItem.Text = AddItem listViewItem.ForeColor = gcolColors(Color) listViewItem.ImageIndex = ImageNumber lstvListView.Items.Add(listViewItem) Dim r As Rectangle = lstvListView.GetItemRect(0) Dim nVisibleItems As Integer = lstvListView.Height \ r.Height If lstvListView.TopItem.Index + nVisibleItems >= lstvListView.Items.Count - 1 Then lstvListView.EnsureVisible(lstvListView.Items.Count - 1) End If End Sub .... End Class
When I cut my function out of the FXPdotNET class and paste it within my main form's class frmMain, it is back working in beta 2. But I don't wanna leave my FXPdotNET class, because I use different Class Constructors to use that class, so putting it within the main class is not a solution for me.Code:Public Class FXPdotNET ..... Public Function Login() As Boolean .... 'This line is giving next error: A first chance exception of type 'System.NullReferenceException' occurred in FXP.EXE 'Notice it was just working fine in beta 1, but not in beta 2 frmMain.lstvErrorMessages.Invoke( _ New frmMain.AddToLstvDelegate( _ AddressOf frmMain.AddToLstv), New Object() _ {frmMain.lstvErrorMessages, "TEST",9, 81}) ... End Function .... End Class
I'm kindly asking you if someone could take a look at it and maybe point me to a solution because I'm totally stuck.
I'd be very greatful.
Thanks
Regards
djrud


Reply With Quote


Bookmarks