The MASM Forum Archive 2004 to 2012

Project Support Forums => IDE Development and Support => RadAsm Support Forum => Topic started by: Lobotomy on September 07, 2006, 02:00:33 PM

Title: Webbrowser threaded: exiting gently
Post by: Lobotomy on September 07, 2006, 02:00:33 PM
Hi Ketil,

I'm trying to launch the WB in a separate thread, but I'm afraid I'm not waiting/exiting or CoUninitialize-ing it correctly, and it sometimes raises an error on quit.

I feel quite guilty asking you for help for a third time in two weeks, but I have no one else to ask :(
Could you happen to have a threaded WB skeleton, or maybe you can spot the bad idea in mine?

I've made the attached code as short as possible to save your time.

[attachment deleted by admin]
Title: Re: Webbrowser threaded: exiting gently
Post by: KetilO on September 07, 2006, 06:06:43 PM
Hi

I'm not an expert in this area.
The idea is to make a controled thread termination. It might work.

KetilO

[attachment deleted by admin]
Title: Re: Webbrowser threaded: exiting gently
Post by: Lobotomy on September 07, 2006, 06:40:50 PM
Thank you very much, Ketil!

I also tried to play with PostThreadMessage, just my code looked much uglier, with "the guy started 3 weeks ago" written between the lines.

Your workaround is working, and looks much less workaroundish than my own attempts.

If you one day accidently stumble upon how it's advised to be done by the headquaters, please post here.

Thank you again, and good luck  :thumbu
Title: Re: Webbrowser threaded: exiting gently
Post by: Lobotomy on September 08, 2006, 03:59:53 PM
Ketil,

Your code contains an interesting puzzle - you actually don't escape the loop:


.elseif uMsg==WM_CLOSE
    invoke PostThreadMessage,IDT_WB,WM_QUIT,0,0
    mov uExit,STILL_ACTIVE
    .while uExit==STILL_ACTIVE
        invoke GetExitCodeThread,hThread,addr uExit
        invoke GetMessage,addr msg,NULL,0,0
        invoke TranslateMessage,addr msg
        invoke DispatchMessage,addr msg
        invoke Sleep,10
     .endw


on WM_CLOSE itself, but an additional interaction with the window is required.

I've noticed it when sending WM_CLOSE on tray icon click - the window won't close unlil mouseover or keyboard. It wasn't noticable in your example as there WM_CLOSE is always from the mouse or keyboard.

I've attached your code with added WM_CLOSE sent on tray icon click, see how strange it looks - thread dies, main window lives.

It's more of a logical puzzle than an urgent matter, but pretty interesting.

[attachment deleted by admin]