Threads
-
Hi All! i would like to get some help regarding creating objects inside a thread. i have a thread and within the thread i am creating an object. main thread { obj o for(;;) { o.createnamedpipe; o.connectnamedpipe; if(connected) { o.createthread; o.startthread; } } } the above scenario always encounters an exception. is it because the obj is no longer valid when the o.startthread is started? i tried to use another thread thread and from there call the startthread... so ill have for(;;) { o.createnamedpipe; o.connectnamedpipe; if(connected) createthread(minorthread, o,...); } minorthread(lpParam) { obj o = static_castlpParam; o.createthread; o.startthread; } this however still fails. hope someone can help me. thanks in advance! newbie :)
-
Hi All! i would like to get some help regarding creating objects inside a thread. i have a thread and within the thread i am creating an object. main thread { obj o for(;;) { o.createnamedpipe; o.connectnamedpipe; if(connected) { o.createthread; o.startthread; } } } the above scenario always encounters an exception. is it because the obj is no longer valid when the o.startthread is started? i tried to use another thread thread and from there call the startthread... so ill have for(;;) { o.createnamedpipe; o.connectnamedpipe; if(connected) createthread(minorthread, o,...); } minorthread(lpParam) { obj o = static_castlpParam; o.createthread; o.startthread; } this however still fails. hope someone can help me. thanks in advance! newbie :)
Notice anything peculiar about your code snippet? Yeah, we can't decipher it either.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Notice anything peculiar about your code snippet? Yeah, we can't decipher it either.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Hi, i am sorry i wrote just words to explain the way i have coded it. basically what i have is a class (CIPCClass) which encapsulates namedpipe functions and in the mainthread i create an instance of that class CIPCClass and when a client has connected i call the startthread of the CIPCClass to continue the receiving of message while the main thread can again continue to listen for connecting clients. mainthread { CIPCClass obj; for(; ; ) { obj.CreatePipe(); int nRet = obj.ConnectNamedPipe(); if(nRet) obj.StartThread(); else break; } } the above approach did not work so i created a minorthread which receives the CIPCClass. and from the minorthread then i will call the startthread. still it did not work. hope i have explained it clear enough. sorry again. thanks for any help. newbie :)
-
Hi All! i would like to get some help regarding creating objects inside a thread. i have a thread and within the thread i am creating an object. main thread { obj o for(;;) { o.createnamedpipe; o.connectnamedpipe; if(connected) { o.createthread; o.startthread; } } } the above scenario always encounters an exception. is it because the obj is no longer valid when the o.startthread is started? i tried to use another thread thread and from there call the startthread... so ill have for(;;) { o.createnamedpipe; o.connectnamedpipe; if(connected) createthread(minorthread, o,...); } minorthread(lpParam) { obj o = static_castlpParam; o.createthread; o.startthread; } this however still fails. hope someone can help me. thanks in advance! newbie :)
If code isn't indented I don't bother to look at it.
Steve
-
Hi, i am sorry i wrote just words to explain the way i have coded it. basically what i have is a class (CIPCClass) which encapsulates namedpipe functions and in the mainthread i create an instance of that class CIPCClass and when a client has connected i call the startthread of the CIPCClass to continue the receiving of message while the main thread can again continue to listen for connecting clients. mainthread { CIPCClass obj; for(; ; ) { obj.CreatePipe(); int nRet = obj.ConnectNamedPipe(); if(nRet) obj.StartThread(); else break; } } the above approach did not work so i created a minorthread which receives the CIPCClass. and from the minorthread then i will call the startthread. still it did not work. hope i have explained it clear enough. sorry again. thanks for any help. newbie :)
Using the <pre&gr tags keep the indentation and any < or > symbols. It will also make it easier on people's eyes to read - so someone might actually answer. Iain.
-
Hi, i am sorry i wrote just words to explain the way i have coded it. basically what i have is a class (CIPCClass) which encapsulates namedpipe functions and in the mainthread i create an instance of that class CIPCClass and when a client has connected i call the startthread of the CIPCClass to continue the receiving of message while the main thread can again continue to listen for connecting clients. mainthread { CIPCClass obj; for(; ; ) { obj.CreatePipe(); int nRet = obj.ConnectNamedPipe(); if(nRet) obj.StartThread(); else break; } } the above approach did not work so i created a minorthread which receives the CIPCClass. and from the minorthread then i will call the startthread. still it did not work. hope i have explained it clear enough. sorry again. thanks for any help. newbie :)
ginjikun wrote:
hope i have explained it clear enough.
What does "did not work" actually mean?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne