943,998 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 6955
  • VB.NET RSS
May 10th, 2006
0

How do you handle events raised by a thread in a seperate class?

Expand Post »
I've got a procedure within a class that will be running something on its own thread. Basically it's a timer that will fire periodically... well when that event fires I want to be able to handle that on a windows form. for example:

the class is a queue, when the event fires I want to fire an event handler and dequeue an item, passing that by reference through the event handler. I then want the windows form to handle the event and using that dequeued item create a listview item and add it to a list view control.

The event does fire, and the windows form does handle the event, but when I try to add the item to the control, I get a cross-thread exception. It's saying that the listview control is being accessed by another thread, but the handler is on the form's code, not the class.

Can anyone tell me what I'm doing wrong?

-SelArom
Similar Threads
Reputation Points: 20
Solved Threads: 1
Junior Poster in Training
SelArom is offline Offline
54 posts
since Oct 2004
May 10th, 2006
0

Re: How do you handle events raised by a seperate thread?

Okay I did some debugging and it seems that the thread that is running is indeed the one that I created to run inside the class. How do I make the main thread capture the event instead of that one, or can I not do that?

-SelArom
Reputation Points: 20
Solved Threads: 1
Junior Poster in Training
SelArom is offline Offline
54 posts
since Oct 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: VB.NET - Date sort in a custom grid
Next Thread in VB.NET Forum Timeline: record results in excel file from vb





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC