TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Andy
NA
1
0
Handling events generated in a thread
Jun 18 2009 1:03 PM
Hi all
I monitor the serial port within a worker thread. As data arrives I buffer it. When the data is complete I copy it in to variable shared with the container class. I generate an event within the worker thread to let the outside world know there is new data.
When the event is detected in the main thread I read a copy of the exposed data from the containing class. I then do things with the data. e.g. write it to a database etc..
When the the device I'm monitoring tells me it has no more data, and I go off and do other things, one action I do is to thread.join the worker thread i.e. I don't need it any more.
The problem is that because the event to finish is generated within the worker thread, all the code called by the worker event seems to be handled within the worker thread, so in effect it cuts its own throat and crashes.
Does anyone know how to set an event in a thread. Pick it up in the main thread and then any further actions transferred over to the main thread?
thanks in advance
Reply
Answers (
0
)
is there a way to determine which project a file belongs? programmatically...
How can a record count be -1?