| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Blocking object window |
Hello Harald,
On May 23 03:28 95, Harald Kipp of 2:2448/404 wrote:
HK> I am trying to set up a 2nd thread to do some
a thread is a function, not a class.
HK> class ServiceThread : public IThread, public IUserHandler
HK> {
HK> public :
HK> ServiceThread(IStaticText* static1);
HK> ~ServiceThread();
HK> void run();
HK> IObjectWindow *myObjectWindow;
HK> protected :
HK> Boolean user(IEvent &evt); // see below
HK> };
i really cant understand why this is derived from IThread. As i said, a
thread is a function, NOT a class.
HK> AMainWindow :: AMainWindow()
HK> :IFrameWindow("Main Window", ID_WINDOW_1)
HK> ,servThread(&any_param)
ok, so now ServiceThread is a MessageHandler for the main thread! (and of
course it runs in the main thread!!!).
HK> I start the thread with
HK> servThread.start(new IThreadMemberFn
HK> (servThread,ServiceThread::run), true);
you are Starting the member function RUN as a thread. but i can't see any
reference to 'run' in the following posted code from you.
HK> servThread.myObjectWindow->handle().postEvent(WM_USER,
HK> IEventParameter1(0), IEventParameter2(0));
the message will be catched by the UserHandler.
BTW: VERY BAD Naming conventions!!! why is youre class called IUserHandler?
IBM's classes are called I*. call your classes HKUserHandler.
HK> class IUserHandler : public IHandler
correct definition for a message Handler.
HK> IEvent userevt(evt);
HK> result = user(userevt);
there is a RESULT returned in event. you should set evt.setresult(userevt.result());
HK> Boolean ServiceThread :: user(IEvent &evt)
remember : this runs in main thread! only RUN is a thread function.
HK> Are you still with me? The problem is, that a DosSleep
HK> (to fake lengthy processing) inserted after either
HK> case WM_USER:
HK> or
HK> case ID_ANY
HK> will block PM. I'm using IBM C/C++ Tools Version 2.01
of course.
HK> If anybody please give me a hint how to implement a
HK> single servicethread processing different events via
HK> PM messages.
you should start the thread from the mainThread and IN the run function you
should install your IUserHandler. create a ServiceThread alike object
(which is NOT derived from IThread and which does not start a run member
anymore) in the 2ns thread. THEN message processing happens in the 2nd
thread.
class MyMainClass
{
public :
MyMainClass() {}
virtual ~MyMainClass() {}
void start();
void stop();
void MyThreadFunc();
private:
IThread Thread;
};
void MyMainClass::start()
{
Thread.start(new IThreadMemberFn (*this,
MyMainClass::MyThreadFunc));
}
// ...
PS: for simple inter thread communication with ICLUI see:
\IBMCPP\WKFRAMES\UILINES\*.cpp
WARPED!, Mario
---
* Origin: LC/32 Development Team-Vienna-Austria (2:310/14.11)SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809 @PATH: 310/14 90 30 2490/1301 240/5500 396/1 270/101 105/103 42 712/515 @PATH: 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.