Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Select Grid Row BY ID
Re: Select Grid Row BY ID [message #48024 is a reply to message #48020] |
Wed, 10 May 2017 19:09   |
Oblivion
Messages: 1206 Registered: August 2007
|
Senior Contributor |
|
|
Hello germax,
Quote:The problem (the reason why I went with multithreading in the first place) is still persistent.
the GUI blanks out and the App is irresponsive for quite some time (until all workes are finished)
Do you really need CoWorker? I don't know the details of your app, but the example you provided is somewhat complicated, imo.
Spawning CoWorkers per row, as your code seems to do, would be an overkill with a considerable overhead.
If all you need is an asynchronous (non-blocking) gui, you can easily use a single worker thread (Thread, not CoWorker) and get rid of the additional vector.
Please find attached a simple example with a csv file over 6000 lines. It simply removes entries one by one without blocking the gui. And it also demonstrates how to halt a thread.
It'll give you the idea, I hope. 
The thread code will look like:
void MTT::processFile()
{
int rowc = grid.GetRowCount();
progin.Percent();
// Below is the actual thread function. We are taking advantage of C++11 lambdas here.
Thread().Run([=] {
for(auto i = rowc - 1, j = 0; i >= 0; i--, j++) {
if(IsShutdownThreads())
break;
// int q = grid(i, 2);
// if(q <= 0)
// this->RemoveItem(i, j); // You can also use a dedicated method.
PostCallback([=] {
grid.Remove(i);
progin.Set(j, rowc - 1);
});
Sleep(10);
}
});
}
Actually you may even not need multithreading at all.
if you are using a for/while loop in single threaded environment which thakes time and thus blocks your app, I mean if that's the only problem, you can use Ctrl::ProcessEvents() to refresh the GUI inside your loop.
E.g.
for(auto i : very_large_vector_to_process) {
DoYourStuff();
ProcessEvents();
}
Regards,
Oblivion
-
Attachment: MTtest.zip
(Size: 26.50KB, Downloaded 300 times)
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Wed, 10 May 2017 20:17] Report message to a moderator
|
|
|
 |
|
Select Grid Row BY ID
By: germax on Fri, 05 May 2017 19:32
|
 |
|
Re: Select Grid Row BY ID
By: deep on Mon, 08 May 2017 15:07
|
 |
|
Re: Select Grid Row BY ID
|
 |
|
Re: Select Grid Row BY ID
By: germax on Wed, 10 May 2017 12:33
|
 |
|
Re: Select Grid Row BY ID
|
 |
|
Re: Select Grid Row BY ID
By: germax on Thu, 11 May 2017 03:33
|
 |
|
Re: Select Grid Row BY ID
|
 |
|
Re: Select Grid Row BY ID
By: germax on Thu, 11 May 2017 20:17
|
 |
|
Re: Select Grid Row BY ID
|
 |
|
Re: Select Grid Row BY ID
By: germax on Fri, 12 May 2017 02:20
|
 |
|
Re: Select Grid Row BY ID
|
 |
|
Re: Select Grid Row BY ID
By: germax on Sat, 13 May 2017 19:13
|
 |
|
Re: Select Grid Row BY ID
|
 |
|
Re: Select Grid Row BY ID
By: germax on Sun, 14 May 2017 19:48
|
 |
|
Re: Select Grid Row BY ID
By: JeyCi on Thu, 18 February 2021 14:45
|
 |
|
Re: Select Grid Row BY ID
By: JeyCi on Fri, 19 February 2021 07:31
|
 |
|
Re: Select Grid Row BY ID
By: deep on Mon, 15 May 2017 07:44
|
 |
|
Re: Select Grid Row BY ID
By: germax on Mon, 15 May 2017 14:22
|
Goto Forum:
Current Time: Sat May 10 20:51:19 CEST 2025
Total time taken to generate the page: 0.00751 seconds
|