Solved

VB.NET - Delegates & Exceptions with ListView

Posted on 2008-11-01
3
382 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

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…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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