Re: How to update display in another thread ?



On Mon, May 09, 2005 at 11:02:10AM -0400, Paul Davis wrote:
> read the FAQ for gtk, which has an entry on threads. 
> and google for "gtkmm dispatcher threads"
> 
-------------------------

I search the mailing list and the reference documentation. And find
the solution. I'm sorry that I didn't do this earlier. The following
is my solution:
	1) In the GUI thread
	   ---window.h---
	   class MainWindow {
		   	public:
		   		...
				void on_dispatcher_notify() { on_expose_event(NULL); }
				void update_display() { dispatcher.emit(); }
			private:
				Glib::Dispatcher dispatcher;
				...
	   };
	   ---window.cpp---
	   MainWindow::MainWindow()
	   {
		   ...
		   dispatcher.connect(sigc::mem_fun(*this, &MainWindow::on_dispatcher_notify));
		   ...
	   }
	 2) In the other thread
	   ----
	   thread_function()
	   {
		   ...
		   wait_for_information(&position);
		   window->set_position(position);
		   window->update_display();
		   ...
	   }


-- 
No one so thoroughly appreciates the value of constructive criticism as the
one who's giving it.
		-- Hal Chadwick




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