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++ Library : Other (not classified elsewhere) » GUI and Thread (Call GUI fonction into thread)
GUI and Thread [message #47061] Thu, 24 November 2016 15:31 Go to next message
lovmy is currently offline  lovmy
Messages: 44
Registered: November 2015
Member

Hi,

Sorry for my English, i'm French and i don't speak very well this language.

I have a problem, i want to print something into a LineEdit into a thread.

This is what I wrote:

void Processus( bool *boucle, LineEdit *l )
{
	while( boucle )
	{
		l->Insert(-1, "test\n" );
		boucle = false;
	}
}

...

void Test::ConnexionClient()
{
...
	Thread::Start( callback2( Processus, &boucle, &client.lignesClient ) );
	boucle = true;
...
}


In lay file i have:

ITEM(LineEdit, lignesClient, LeftPosZ(7, 601).TopPosZ(85, 253))


I have this error when i execute my program:

http://banaszak.fr/thread.png

Can you help me ? How to use GuiLock ?

I'm using TheEDI Windows edition.

Thank you !
Re: GUI and Thread [message #47062 is a reply to message #47061] Thu, 24 November 2016 18:52 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
Take a look at this example: http://www.ultimatepp.org/reference$GuiLock$en-us.html
This should fix your problem:
void Processus(bool *boucle, LineEdit *l)
{
	while(boucle)
	{
		{
			GuiLock __;
			l->Insert(-1, "test\n" );
		}
		boucle = false;
	}
}

[Updated on: Thu, 24 November 2016 18:53]

Report message to a moderator

Re: GUI and Thread [message #47063 is a reply to message #47061] Fri, 25 November 2016 10:21 Go to previous messageGo to next message
lovmy is currently offline  lovmy
Messages: 44
Registered: November 2015
Member

Hi !

OK it's work.

I have just a little problem, i want into my thread write into the LineEdit the data received in a socket connexion.

If i have in .h file:

static TcpSocket connexion;


and

void Processus( bool *boucle, LineEdit *l )
{
	while( boucle )
	{
		char ServerResponse[10];
		ConnexionTCP::connexion.Get(ServerResponse, 10);
		GuiLock __;
		...
	}
}


I have undefined error in linking in other method of my class:

void ConnexionTCP::fermerConnexion( void )
{
	if( connexion.IsOpen() )
		connexion.Close();
}


If i remove "static", i have no error but i can't acces to connexion into my thread.

I thing it's probably a C++ syntax error but can you help me ?

Thank you !!!
Re: GUI and Thread [message #47064 is a reply to message #47061] Fri, 25 November 2016 10:31 Go to previous message
lovmy is currently offline  lovmy
Messages: 44
Registered: November 2015
Member

Hi,

Sorry i'm stupid, i forgot to declare:

TcpSocket ConnexionTCP::connexion;


into cpp file.

Now it's OK.

Thank you for your help, Ultimate C++ is very good !
Previous Topic: Version of libmysqlclient.so
Next Topic: Convert Upp::String to int
Goto Forum:
  


Current Time: Fri Dec 13 21:46:28 CET 2024

Total time taken to generate the page: 0.03236 seconds