Solved

VB.NET - Delegates & Exceptions with ListView

Posted on 2008-11-01
3
386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

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 86

Expert Comment

by:Mike Tomlinson
ID: 22860565
No idea...that one makes no sense...  =\
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

624 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