Click here to Skip to main content
15,911,531 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questiona blowfish decrypt/encrypt related question Pin
Torune2-Sep-05 16:03
Torune2-Sep-05 16:03 
QuestionCreating a colored, transparent CStatic Pin
David Fleming2-Sep-05 14:00
David Fleming2-Sep-05 14:00 
AnswerRe: Creating a colored, transparent CStatic Pin
David Fleming2-Sep-05 22:59
David Fleming2-Sep-05 22:59 
QuestionAbsent Thread Pin
Blake Miller2-Sep-05 10:53
Blake Miller2-Sep-05 10:53 
AnswerRe: Absent Thread Pin
Gary R. Wheeler3-Sep-05 2:36
Gary R. Wheeler3-Sep-05 2:36 
QuestionWhat do employers mean by .Net experience Pin
Brian R2-Sep-05 9:31
Brian R2-Sep-05 9:31 
AnswerRe: What do employers mean by .Net experience Pin
Chris Losinger2-Sep-05 10:43
professionalChris Losinger2-Sep-05 10:43 
QuestionThreading problem.. Pin
Laing,James2-Sep-05 8:42
Laing,James2-Sep-05 8:42 
I have a WIN32 application that creates and dispatches a number of threads that perform various tasks.
Now, one of the threads in particular creates and dispatches another two threads; one which reads records into a list <cstring> and one which writes the records from the list to an output.

The threads are created by a call to AfxBeginThread(), specifying the name of the function that serves as the worker thread (not a member function), and the argument to the call is the 'this' pointer of the parent object creating the thread (Both workers need access to the member functions of their parent).

When the number of lines to read and subsequentailly write, is small, ie) one or two. I get a really strange thread protection expception.

1. The parent dispatches the first thread; the reader. It starts right away.
2. The parent dispatches the second thread; the writer. It starts right away.
3. The parent thread then hits a WaitForMultipleObjects(), waiting for an event to be signalled by
both child threads indicating that they are complete.
4. The wait is broken, the parent object goes through destruction and completes.
5. Protection exception.

Thrdcore.cpp @ line 114 (in my listing).

nResult = (*pThread->m_pfnThreadProc)(pThread->m_pThreadParams);

I cannot for the life of me find out what the problem is. It is as if a thread is being dispatched
again after the parent is complete, or there is some kind of thread-clean-up that expects the function pointed to by pThread->m_pfnThreadProc and its argument pThread->m_pThreadParams (which is the address of the parent object) to be still accessible. Which of course it cannot be as the parent object has already been destroyed.

I have traced the process over and over and I cannot come up with a reason why this is happening.
If anyone has any suggestions or pointers I would would very much appreciate them.

James.
AnswerRe: Threading problem.. Pin
Gary R. Wheeler3-Sep-05 2:43
Gary R. Wheeler3-Sep-05 2:43 
GeneralRe: Threading problem.. Pin
Laing,James3-Sep-05 7:27
Laing,James3-Sep-05 7:27 
Question:: operator Pin
celllllllll2-Sep-05 7:47
celllllllll2-Sep-05 7:47 
AnswerRe: :: operator Pin
PJ Arends2-Sep-05 8:26
professionalPJ Arends2-Sep-05 8:26 
GeneralRe: :: operator Pin
celllllllll2-Sep-05 8:50
celllllllll2-Sep-05 8:50 
GeneralRe: :: operator Pin
PJ Arends2-Sep-05 9:03
professionalPJ Arends2-Sep-05 9:03 
GeneralRe: :: operator Pin
celllllllll6-Sep-05 10:28
celllllllll6-Sep-05 10:28 
QuestionCPreviewView Class Pin
mikobi2-Sep-05 7:18
mikobi2-Sep-05 7:18 
AnswerRe: CPreviewView Class Pin
PJ Arends2-Sep-05 8:21
professionalPJ Arends2-Sep-05 8:21 
GeneralRe: CPreviewView Class Pin
mikobi2-Sep-05 20:29
mikobi2-Sep-05 20:29 
GeneralRe: CPreviewView Class Pin
mikobi2-Sep-05 20:43
mikobi2-Sep-05 20:43 
GeneralRe: CPreviewView Class Pin
PJ Arends3-Sep-05 8:57
professionalPJ Arends3-Sep-05 8:57 
GeneralRe: CPreviewView Class Pin
mikobi4-Sep-05 21:18
mikobi4-Sep-05 21:18 
GeneralRe: CPreviewView Class Pin
PJ Arends4-Sep-05 21:32
professionalPJ Arends4-Sep-05 21:32 
GeneralRe: CPreviewView Class Pin
mikobi5-Sep-05 3:12
mikobi5-Sep-05 3:12 
GeneralRe: CPreviewView Class Pin
mikobi5-Sep-05 6:49
mikobi5-Sep-05 6:49 
QuestionRS232 problem Pin
transoft2-Sep-05 6:19
transoft2-Sep-05 6:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.