Long non-GUI tasks



Hi all,

I'm faced with a potentially sticky situation. I need to make an API 
call to an external library which may possibly last on the order of 
magnitude of seconds to minutes. I do not maintain this library, so 
I can't place any gtk_main_iteration() calls anywhere *within* the 
library function in question.

So my plan was to open a small progress box and display a 
message, indicating that this will take some time. However, if I call 
the function immediately after showing the progress box using 
gtk_widget_show(), the contents of the box are not displayed! I 
tried doing something like:

	for (i = 1; i < 100; i++)
	{
		gtk_main_iteration();
	}

but this causes the program to freeze every once in a while. I also 
tried:

	while (gtk_events_pending())
	{
		gtk_main_iteration();
	}

but the contents still don't appear on the dialog box, even though 
I've shown the box before I've shown the window.

Is there a way to handle this situation in a clean way? I tried 
looking into GNU Pth for possible threading means, but it does not 
support preemptive threads (otherwise this problem won't be 
solved).

Thanks,
--Arthur



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]