Does thread #2 have access to CCoeEnv of thread #1

Login to reply to this topic.
Wed, 2003-05-07 18:25
Joined: 2003-05-01
Forum posts: 3
I have an app with a UI that creates another thread (#2). Thread #2 has no UI, but needs to have access to the process' CCoeEnv object. Calling CCoeEnv::Static() in thread #2 gives me an invalid environment. Any attempt to use the CCoeEnv object returned, results in a GPF (emulator).

My question is: Can thread #2 use thread #1's CCoeEnv if I pass #2 the pointer to #1's object as a parameter to the RThread::Create() function?

I'm going to begin writing the code for it but if somebody can tell me I'm wasting my time, please do

Thu, 2003-05-08 01:32
Joined: 2003-04-01
Forum posts: 37
Does thread #2 have access to CCoeEnv of thread #1
in symbian, Active Object is preferable to Thread...

ouseka

Thu, 2003-05-08 08:23
cfm (not verified)
Forum posts: 2043
Does thread #2 have access to CCoeEnv of thread #1
As far as I know, the CEikonEnv/CCoeEnv pointer is stored in the TLS area of the app thread.  This means that only that threat will have access to it.  Calling CCoeEnv::Static in any other thread will return a random pointer.

You can try passing the CCoeEnv pointer from the app thread to the second thread on creation and see if it is usuable.  There may be some issues, but worth a try.
Thu, 2003-05-08 14:42
Joined: 2003-05-01
Forum posts: 3
Does thread #2 have access to CCoeEnv of thread #1
Thank you both for your input.  An active object doesn't work in this situation and I've tried passing the CCoeEnv ptr to the second thread but using it causes a panic.

I also tried to create a new CCoeEnv object in the second thread and it appears to work (at least the limited number of functions that I use), but when I delete it, I get an ALLOC: xxxxxxxx error.  I even tried calling DestroyEnvironment() on it before deleting it but no help.
Fri, 2005-07-01 09:45
Forum Nokia Champion
Joined: 2003-10-01
Forum posts: 723
Re: Does thread #2 have access to CCoeEnv of thread #1
Have you tried to pass a function pointer in Create()? I'm just thinking about that if you shared a function of thread #1 with thread #2, then it would be a good way for communication. That is, when thread #2 needs to perform an action that requires UI, then it would simply call this function, which would then run in thread #1 context.

Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/

  • Login to reply to this topic.