문제

I have a plugin where I want to prevent the browser from closing as im saving some data that take a unknown random amount of time.

data_ready = false;
data_ready = saveData(); //using a random amount of time as the user has to specify a location
boost::unique_lock<boost::mutex> lock(mut); 
while(!data_ready)  {
    cond.wait(lock);
}

Asking location for saving the data is prompted but crashes immediately after, which im guessing is the lock. How could I make the browser wait for the user to be finished saving data?

도움이 되었습니까?

해결책

You can't. It is up to you to make sure that the plugin never blocks the main thread and that all threads you start are shut down in time. Congratulations and welcome to the wonderful world of browser plugins =]

Some people have gotten around this by launching an external application that does the real work that won't close until it's done.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top