Thx Andrea,
Well the problem is that all your solutions seems to "block" my main thread.
When I run WaitForSingleObject(), the main thread is blocked on this
statement, then my user interface is completely frozen, what I dont want.
Same thing with a loop until process is alive, I won't be able to use my UI.
The idea should be to create an event which will be fired from my
working thread, and caught into my main thread... but I've been looking
and trying a lot of thing this afternoon and finally nothing works ...
I can't beleive that a such thing is undoable, the sdk timer works like
this, it runs in another thread, but fire an event in the main thread...
So it must be possible !
> there are three ways:
>
[quoted text clipped - 28 lines]
>>
>>Thx in advance !
andrea catto' - 07 May 2004 18:33 GMT
trust me it's all doable,
I just need to get more into details of what Ecactly you need to do.
I understand now the main() needs to also do other things instead of
blocking.
From what I understand so far, the main() needs to be operating in the
meanwhile instead of waiting.
it really depends on what you need to be doing in the main() though, if you
are doing some other stuff such as updating files, UI and so on...
there must be a while/loop that does so, in which you routinely check a
given global flag without even the need of an event.
if you must be able to update UI and do other OS things and in any give
time, even during those things are still working, the worker thread needs to
be
doing things, well, such a thread will have to spawn it's own
multitasked/overlapped code.
just remember that, you can not / not supposed to INTERRUPT a major OS
call...
example:
if the main() you are doing long term operations such as file creations and
another thread wants to 'somehow' interrupt those main()'s operations that
are still operating...
the result could be catastrophic.
interrupting the an OS function in the middle of the flow, generally loses
permanently 1MB of stack, doesnt free rerources and corrupts data.
the approaches are after all some of these:
1) you loop in the main until a flag is changed, and in the loop you do your
updates and operations.
2) you WaitForSingle/MultipleObjects doing nothing until an event in fired
by a worker thread.
3) if you dont want a loop/flag, and yet you have to do things, you can
always have the main() do certain update operations... and let it take how
ever long it takes...
prespawn the worker thread so it also operates in an overlapped fashion,
after the main()'s code is done with its deal, instead of the loop, put a
WaitForSingleObject on the worker thread's handle.
this way the main may take any time needed, however long, and
'synchronize' with the worker thread whenever it ends
> Thx Andrea,
>
[quoted text clipped - 45 lines]
> >>
> >>Thx in advance !