| | |
How do you handle events raised by a seperate thread?
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
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
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
You are somebody, just as I am somebody... but in the end, when you REALLY think about it, we are all nobody...
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
-SelArom
You are somebody, just as I am somebody... but in the end, when you REALLY think about it, we are all nobody...
![]() |
Similar Threads
- Set, View, Change, or Remove Special Permissions for Files and Folders in Windows XP (Windows tips 'n' tweaks)
- Send data on a serial port (C++)
- ComboBox Events (VB.NET)
- B.Sc Thesis Project (VB.NET)
- storing references to classes (C++)
- HJT log ~ help please! :) (Viruses, Spyware and other Nasties)
- Address Book Application... (here's what I have done so far..) (C++)
- weird popup (Windows NT / 2000 / XP)
Other Threads in the VB.NET Forum
- Previous Thread: VB.NET - Date sort in a custom grid
- Next Thread: record results in excel file from vb
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add arithmetic array assignment basic binary bing box button buttons center code combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel file-dialog firewall folder google hardcopy image images isnumericfuntioncall listview login math memory mobile module ms mssqlbackend mysql navigate net networking opacity output pan peertopeervideostreaming picturebox picturebox1 plugin port print printpreview problemwithinstallation project record reports" reuse save savedialog serial sorting sql storedprocedure string temp text textbox timer toolbox updown upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf





