0

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

1
Contributor
1
Reply
3
Views
10 Years
Discussion Span
Last Post by SelArom
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.