changing current thread 
Author Message
 changing current thread

To anyone,
    I am pretty sure I have seen this done in some of the MFC src code but I
cannot find it now.  I want to change the thread a module is running in to
the main thread so that I have access to the main window handles so I can
create documents/windows.  I am not sure if this is even possible but from
what I have read about the way the thread states are maintained it seems
possible for a thread to do this for a short period of time as long as it
switches back.  Anyone know how this is done?
    I have a JNI thread executing concurrently with a main mfc thread. The
JNI makes callbacks to the mfc application to open windows/documents.
Problem is, the JNI portion is running its own thread.  It is the same as if
I were doing this with a CWinThread and making some call to open a
window/document.  What I do not want to do is post thread messages or other
window messages to get across the thread barrier.

Chris Fahey



Fri, 19 Apr 2002 03:00:00 GMT  
 changing current thread

Quote:

> ...
> What I do not want to do is post thread messages or other
> window messages to get across the thread barrier.

Why not?  The problem, as with any interthread access, is synchronization.  The
reason MFC won't let you get at the MFC windows from another thread is that MFC
might be in the midst of handling a message when your thread accessed its data.
So, on first principles the thing that you have to synchronize with is MFC's
message pump.  Feeding something (Post/Send) through the message queue is just
about the only way to do that.

--
Scott McPhillips [VC++ MVP]



Fri, 19 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. determining if current thread is main thread

2. Determine if current thread is a worker thread

3. Changing the amount of available threads in thread pool

4. OpenThreadToken fails for current thread

5. Detecting window with current focus (even in another thread)

6. Detecting window with current focus (even in another thread)

7. wait (or sleep) for current thread

8. How to get the id of the current unnamed thread?(NT)

9. Current thread

10. changing current dir

11. Q: How to change current directory in unix cc

12. Which API to change current drive?

 

 
Powered by phpBB® Forum Software