Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
slashkyle
Posts: 800
Registered: ‎10-16-2012
My Device: Red Z10, Dev Alpha C
My Carrier: Telus
Accepted Solution

MultiThreading with QtConcurrent issue (Sample)

[ Edited ]

using an example I was able to setup QConcurrentRun & a watcher to create a new thread, process events  & update once completed.

 

The only issue is, when i click the run button in 10.2 i get a  pop up error 

An internal error occurred during: "Executing run".
Invalid thread access

but if i right click on the project folder -> run as -> blackberry c/c++ application the application builds, launches deploys and everything appears to be working correctly.

 

I've attached a sample project that demonstates the issue & how to process events in other threads somewhat easily

Please use plain text.
Developer
slashkyle
Posts: 800
Registered: ‎10-16-2012
My Device: Red Z10, Dev Alpha C
My Carrier: Telus

Re: MultiThreading with QConcurrent issue (Sample)

* I just incorporated the functionality of this into my main project and never got a launch error so it is possible that it may have just been momentics playing funny with me*

 

Please use plain text.
Developer
simon_hain
Posts: 15,874
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: MultiThreading with QConcurrent issue (Sample)

to quote @nedbat from twitter:
Some people, when confronted with a problem, think, "I know, I'll use threads," and then two they hav erpoblesms.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
slashkyle
Posts: 800
Registered: ‎10-16-2012
My Device: Red Z10, Dev Alpha C
My Carrier: Telus

Re: MultiThreading with QConcurrent issue (Sample)

[ Edited ]

I read all the aruments against threads before I proceeded, partly why I chose to use QtConcurrent::run to carry the legwork for me it's supposed to be threadsafe (for the most part),  Threading wasn't something I particularly wanted to do (very glad this method was possible) the functions that I'm going to be working with do require some processing to be done at the same time as other functions run, but if it's done on the same thread one process gets delayed by the other causing my feature to not work

Please use plain text.
Developer
simon_hain
Posts: 15,874
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: MultiThreading with QConcurrent issue (Sample)

i am also using QtConcurrent::run, including the full QFutureWatcher thing, works well as long as you don't try to use the parent mechanism which seems not to work with different threads.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
slashkyle
Posts: 800
Registered: ‎10-16-2012
My Device: Red Z10, Dev Alpha C
My Carrier: Telus

Re: MultiThreading with QConcurrent issue (Sample)

I discovered what was causing the invalid thread warning issue, momentics for some reason created another run configuration titled  qdelaunch, after deleting those configs it allows for the run button to be clicked directly from the from the toolbar.

 

 

Please use plain text.