Solved

VB.NET - Delegates & Exceptions with ListView

Posted on 2008-11-01
3
380 Views
Last Modified: 2012-05-05
I have a timer that updates a ListView.. the code is:

        If ListView.InvokeRequired Then
            If ListView Is Nothing Then
                ' temp
            Else
                ListView.Invoke(New PopulateListViewDelegate(AddressOf PopulateListView), ListView)
            End If
        Else
            PopulateListView(ListView)
        End If


I'm getting an error on the line: ListView.Invoke(New PopulateListViewDelegate(AddressOf PopulateListView), ListView)

The error is the standard first chance exception about declaring the object with "New" (the whole line is highlighted so I'm not sure which object its talking about)

I'm not sure what I'm doing wrong, this appears to work fine and then randomly bugs out on me...

Could this object error be in the PopulateListView Sub but showing here?
0
Comment
Question by:mcainc
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
Try it this way:

        If Me.InvokeRequired Then
            Me.Invoke(New PopulateListViewDelegate(AddressOf PopulateListView), New Object() {ListView})
        Else
            PopulateListView(ListView)
        End If
0
 

Author Comment

by:mcainc
Comment Utility
thanks, im having another similar weird issue in this sub

    Private Sub StartClient(ByVal Index As Integer)
        client(Index) = New ChatClient

        Thread.Sleep(100)
        client(Index).Initialize(Index)
        client(Index).Start()
    End Sub


I get the NullReferenceException "Object reference not set to an instance of an object" on the line: client(Index).Initialize(Index)

Do you have any idea why this might happen?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
No idea...that one makes no sense...  =\
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now