Threading and messages

I have a class which does downloading in a separated thread. For example:

[code]class FileManager:public Thread, public MessageListener
{
public:
void* result;
FileManager(void);
virtual void handleMessage (const Message& message);
void run();
};

void FileManager::run()
{
downloadBigFile();
StatusMessage* msg= new StatusMessage(SuccessStat);
postMessage( msg);
}[/code]

and a UI component, which runs thread to download a file:

class SomeComponent: public Component, public MessageListener { void runLoading(); virtual void handleMessage (const Message& message); }
What I want is to receive a message from FileManager inside handleMessage
How should I bind FileManager and SomeComponent to be able to handle messages? Something related to MessageManager ?

Thanks

//corrected code

It sounds like you want to pass arbitrary messages from one thread to another?

yes
Here is my message class:

class StatusMessage: public Message { int m_status; public: StatusMessage(int stat); ~StatusMessage(void); int status(){return m_status;} };
And I want to notify Main UI thread that donwloading is completed and to do something like

So make the thread post a message to the thing you want to notify… (?)

That is my question. How to post it exactly to my component?

That is my question. How to post it exactly to my component?[/quote]

With MessageListener::postMessage() !

I do it like

but cannot receive it in

Then you’re posting it to the wrong place.

I post it in the thread I want to receive a message from.
I’ve found this thread http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=2869
It appears that MessageListener cannot listen to messages from another thread.

[quote=“acid”]I do it like
CODE: SELECT ALL
postMessage( msg);

but cannot receive it in
CODE: SELECT ALL
SomeComponent::handleMessage[/quote]

you need to do

SomeComponent->postMessage(msg)

It appears that i need to pass pointer to the component to the 2nd thread and then it works.
Thank you.