Solved

VB.NET - Delegates & Exceptions with ListView

Posted on 2008-11-01
3
383 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
ID: 22860312
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
ID: 22860553
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
ID: 22860565
No idea...that one makes no sense...  =\
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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