Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » How to update main thread UI when runing other thread
Re: How to update main thread UI when runing other thread [message #24965 is a reply to message #24964] Sat, 06 February 2010 11:32 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13976
Registered: November 2005
Ultimate Member
jiuzhi wrote on Sat, 06 February 2010 04:17

Thread work;
engine->working(true);
work.Run(callback(engine,&hEngine::getData));//-getData will do some UI refresh;
while (engine->working()){
  Refresh();//It cann't update UI here;
  Sleep(100);
}

I have thought of a solution is packaged into a function, and create a new Thread to run it;But it is too cumbersome.
In MFC,I can use PeekMessage;
In delphi,I can use Application.ProcessMessage;
Is there a similar solution in u++?


I am not quite sure what the problem is. However, here are several hints:

First, in U++, only main thread does GUI.

PostCallback - any thread can post a callback that gets executed in the main thread

GuiLock - any thread can access GUI objects directly

Ctrl::Call - you can even "call" routines in the main thread. This is done by placing callback to the queue and waiting until it gets processed by the main thread. In fact, most calls to Ctrl routines, like performing message loop, automatically redirect to the main thread using this Call (or similiar ICall).

Please check these examples:

reference/GuiLock
reference/GuiMT
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [SOLVED] File upload example
Next Topic: File upload to https [SOLVED]
Goto Forum:
  


Current Time: Sun May 12 05:26:52 CEST 2024

Total time taken to generate the page: 0.02630 seconds