How to do inter-thread communication

Discussions about using 3rd party extension with OpenOffice.org
Post Reply
LRN
Posts: 2
Joined: Tue May 10, 2011 10:55 am

How to do inter-thread communication

Post by LRN »

Let's say that i need to do something time-consuming. The normal way to go about it is to create a thread and make it do the work, then report back with the result.

Creating a thread is not difficult. The real question is how to communicate the result *back* from the worker thread to the main thread of my office extension. Extensions, AFAIK, do not run an event loop, so there might not even *be* a "main thread" of an extension at a given moment, just the office doing its thing. I thought that maybe i could register an XJobExecutor and then use the XAsyncJob to queue a job from the worker thread to be executed in the main thread - but it's difficult to find examples of something like this, and the SDK is almost completely silent on the subject of thread-safety.

This is compounded by the fact that i'm using Python (so i will probably need to use *processes* instead of threads (thank you, GIL!), which adds a whole new set of problems with regard to communication), and Python examples are almost non-existent (SDK has 1 (/one/) Python component example).
LibreOffice 3.2 NT 6.1.7601
sasa
Posts: 11
Joined: Wed Feb 08, 2017 12:54 am

Re: How to do inter-thread communication

Post by sasa »

Hi,

you can try solution in this thread, tested in dialogs and sidebar extension:
viewtopic.php?f=20&t=89503

Best
LibreOffice 6.3 on Xubuntu 18.04
psilocybe
Posts: 108
Joined: Thu Jun 15, 2017 5:33 am

Re: How to do inter-thread communication

Post by psilocybe »

Hi LRN,

Take a look at my http server https://github.com/prrvchr/OAuth2OOo/bl ... dserver.py
It does two things.
- Waiting for a response from the OAuth2 consent screen ...
- Response with the appropriate redirect link.
LibreOffice 5.3.3.2 - Lubuntu 16.10 - LxQt 0.11.0.3
Post Reply