How to make asynchronous function call to synchronous ?

View: New views
2 Messages — Rating Filter:   Alert me  

How to make asynchronous function call to synchronous ?

by withjazz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi.

I'm developing a HTML WYSIWYG application using gecko engine.
I faced a problem which is about synchronous issue.
It seems that function, eg. nsIWebNavigation::LoadURI,
nsIWebBrowserPersist::SaveDocument, dosen't wait the end of process their
own, it means I also should wait the notification message, so I want to ask
that there is a way to make those asynchronous function to synchronous
function.

I want to try like this,

void Function()
{
    persist->SaveDocument(...);

    LaunchBrowser(...);     // But I don't make sure saving the HTML file is
finished.
}


Thanks,

-- Scott.



_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Re: How to make asynchronous function call to synchronous ?

by Boris Zbarsky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/16/09 6:06 AM, Scott Lee wrote:
> I'm developing a HTML WYSIWYG application using gecko engine.
> I faced a problem which is about synchronous issue.
> It seems that function, eg. nsIWebNavigation::LoadURI,
> nsIWebBrowserPersist::SaveDocument, dosen't wait the end of process their
> own, it means I also should wait the notification message

That's correct; these functions depend on the event loop being spun to
complete.

> so I want to ask
> that there is a way to make those asynchronous function to synchronous
> function.

You could spin the event loop after calling the function, I suppose,
until the operation completes...  Or you could use a callback to do
whatever you want to do on operation completion.

-Boris
_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding