Solved

VB.NET - Delegates & Exceptions with ListView

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
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…

739 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