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 » ArrayCtrl, HeaderCtrl & GridCtrl » Select Grid Row BY ID
Re: Select Grid Row BY ID [message #48028 is a reply to message #48025] Thu, 11 May 2017 20:04 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Hello germax, and you're welcome.
Ultimate++ forums are full of helpful people. Smile

Quote:
Your example is just what I wanted.. it doesn't explain to me why mine didn't work,
but all I care about now is that it DOES work one way or another Very Happy so I'm good.


Sorry I forgot to write that, The reason is actually pretty simple. You use CoWork::Finish(), which is blocking.
You should have used CoWork::IsFinished() instead.
In that case, all you need to call is Ctrl::ProcessEvents(). But still, CoWork seems to me an overkill here. Smile

All you need to do is to alter your code as below (Of course you don't need to use lambda functions and while in the example accessing the vector from threads does not pose classic conncurrency problems, you should consider using mutex (CoWork::Finlock() will do fine. See docs and tutorials for more explanation.):
void MTT::processFile()
{
	int rowc = grid.GetRowCount();
	Vector<bool> del;
	del.SetCount(rowc, false);
	progin.SetTotal(rowc);
	progin.Percent();
	
	for(int i=0; i < rowc; i++)
		cw & [=, &del] {
			// Now, this isn't the proper way to accaess shared elements (UI or core) from a
			// thread. But ONLY in this example, it won't do harm.
			grid.GetRow(i);
			int q = grid(i,2);
			if(q <= 0)
//			CoWork::FinLock();
			del.Set(i, true);
		};
	// cw.Finiehed()
	// Non blocking way:
	while(!cw.IsFinished())
		ProcessEvents();
		
	for(int i = rowc-1; i>=0; i--)
	{
		progin++;
		if(del[i]) grid.Remove(i);
		ProcessEvents();
	}
	RDUMP(del);
}




This is all you need to do. Smile


Regards.

Oblivion.


[Updated on: Thu, 11 May 2017 20:20]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Minor "mistake" in <CtrlLib/ArrayCtrl.h>
Next Topic: Insert Ctrl editors in a single row of ArrayCtrl
Goto Forum:
  


Current Time: Mon Apr 29 01:56:47 CEST 2024

Total time taken to generate the page: 0.03298 seconds