Long time operations - What's the best way?

View: New views
7 Messages — Rating Filter:   Alert me  

Long time operations - What's the best way?

by Perry Werneck :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm not sure if it's the right list to ask for help but I'm having a problem
to implement a uno object on C++ and I'm need some help!

The problem: I'm working in an OXT module allowing a starbasic script  to
get informations from a 3270 host using tn3270e; the service itself is ok
and all the network stuff is running in a separate thread but, some part of
the code needs to wait for any kynd of host response; when I do this all the
OpenOffice.org ui hangs.

I'm looking for some function cal to keep the UI responsive even if the
starbasic script is waiting; something like the gtk_main_iteration() call.

Is it possible in uno code? How can I do this?


--
Perry Werneck
Brasília - DF

Ogden Nash <http://www.brainyquote.com/quotes/authors/o/ogden_nash.html>  -
"The trouble with a kitten is that when it grows up, it's always a cat."

Re: Long time operations - What's the best way?

by andreas.bregas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Perry,

> I'm not sure if it's the right list to ask for help but I'm having a problem
> to implement a uno object on C++ and I'm need some help!
>
> The problem: I'm working in an OXT module allowing a starbasic script  to
> get informations from a 3270 host using tn3270e; the service itself is ok
> and all the network stuff is running in a separate thread but, some part of
> the code needs to wait for any kynd of host response; when I do this all the
> OpenOffice.org ui hangs.
>
> I'm looking for some function cal to keep the UI responsive even if the
> starbasic script is waiting; something like the gtk_main_iteration() call.

although I don't know what could be called in C++ or UNO to
achive this, it may also help you to get some Basic related
information. It's also possible to send Basic into a waiting
loop that keeps the UI responsive by using the wait command,
e.g.:

sub main
     while true
         wait 1000       ' 1000 ms = 1 s
         print "Hello"
     wend
end sub

The UI is responsive while running this program. Instead of the
print command you could call your extension to ask if there was
a host response or a failure or whatever and then exit the loop.

Regards

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Long time operations - What's the best way?

by andreas.bregas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Perry,

> I'm not sure if it's the right list to ask for help but I'm having a problem
> to implement a uno object on C++ and I'm need some help!
>
> The problem: I'm working in an OXT module allowing a starbasic script  to
> get informations from a 3270 host using tn3270e; the service itself is ok
> and all the network stuff is running in a separate thread but, some part of
> the code needs to wait for any kynd of host response; when I do this all the
> OpenOffice.org ui hangs.
>
> I'm looking for some function cal to keep the UI responsive even if the
> starbasic script is waiting; something like the gtk_main_iteration() call.

although I don't know what could be called in C++ or UNO to
achive this, it may also help you to get some Basic related
information. It's also possible to send Basic into a waiting
loop that keeps the UI responsive by using the wait command,
e.g.:

sub main
     while true
         wait 1000       ' 1000 ms = 1 s
         print "Hello"
     wend
end sub

The UI is responsive while running this program. Instead of the
print command you could call your extension to ask if there was
a host response or a failure or whatever and then exit the loop.

Regards

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Long time operations - What's the best way?

by Mathias Bauer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Perry Werneck wrote:

> Hi,
>
> I'm not sure if it's the right list to ask for help but I'm having a problem
> to implement a uno object on C++ and I'm need some help!
>
> The problem: I'm working in an OXT module allowing a starbasic script  to
> get informations from a 3270 host using tn3270e; the service itself is ok
> and all the network stuff is running in a separate thread but, some part of
> the code needs to wait for any kynd of host response; when I do this all the
> OpenOffice.org ui hangs.
>
> I'm looking for some function cal to keep the UI responsive even if the
> starbasic script is waiting; something like the gtk_main_iteration() call.
>
> Is it possible in uno code? How can I do this?

If you want to execute code outside of the GUI thread you have to
implement it in Java or C++. OOo Basic does not have support for threads.

The "wait" call mentioned by Andreas is a dirty workaround but perhaps
it works for you.

Ciao,
Mathias

--
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "nospamformba@...".
I use it for the OOo lists and only rarely read other mails sent to it.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Long time operations - What's the best way?

by Perry Werneck :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

My code is in C++, but, it is designed to be called from a OOo Basic macro.
The netork stuff is running in a separated thread but it would be nice to
the starbasic developers if I can implement some kind of "waitfor" method.

The "wait" call mencioned is a great solution but it makes the development
more complex for the basic part.

2009/9/10 Mathias Bauer <nospamforMBA@...>

> Perry Werneck wrote:
>
> > Hi,
> >
> > I'm not sure if it's the right list to ask for help but I'm having a
> problem
> > to implement a uno object on C++ and I'm need some help!
> >
> > The problem: I'm working in an OXT module allowing a starbasic script  to
> > get informations from a 3270 host using tn3270e; the service itself is ok
> > and all the network stuff is running in a separate thread but, some part
> of
> > the code needs to wait for any kynd of host response; when I do this all
> the
> > OpenOffice.org ui hangs.
> >
> > I'm looking for some function cal to keep the UI responsive even if the
> > starbasic script is waiting; something like the gtk_main_iteration()
> call.
> >
> > Is it possible in uno code? How can I do this?
>
> If you want to execute code outside of the GUI thread you have to
> implement it in Java or C++. OOo Basic does not have support for threads.
>
> The "wait" call mentioned by Andreas is a dirty workaround but perhaps
> it works for you.
>
> Ciao,
> Mathias
>
> --
> Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
> OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
> Please don't reply to "nospamformba@...".
> I use it for the OOo lists and only rarely read other mails sent to it.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>
>


--
Perry Werneck
Brasília - DF

Joan Crawford<http://www.brainyquote.com/quotes/authors/j/joan_crawford.html>
- "I, Joan Crawford, I believe in the dollar. Everything I earn, I
spend."

Re: Long time operations - What's the best way?

by Peter Eberlein-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Perry,
Perry Werneck schrieb:
> Hi,
>
> My code is in C++, but, it is designed to be called from a OOo Basic macro.
> The netork stuff is running in a separated thread but it would be nice to
> the starbasic developers if I can implement some kind of "waitfor" method.
>
> The "wait" call mencioned is a great solution but it makes the development
> more complex for the basic part.
>

If I understood you correctly, you can misuse the listener concept in
Basic as following:
Implement a XMyListener Interface in your Service "MyService" and a
method "hasBeenDone" written in C++.

In Basic:
myService = createUnoService("com.myComp.MyService")

myListener = CreateUnoListener("ThreadStuff_", "com.myComp.XMyListener")

myService.doTheThreadStuff(myListener)

'replacement for the wait() function
do
loop until bIsDone

Function ThreadStuff_hasBeenDone() as Any
     'invoked when your Service has done the thread stuff
     'set a global variable to true
     bIsDone = true
End Function

An example you find here [1]

Regards


Peter

[1] http://www.oooforum.org/forum/viewtopic.phtml?t=29820


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: Long time operations - What's the best way?

by Perry Werneck :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Thanks! The "wait" call worked after some changes in the C++ code moving all
the 3270 communication to another thread.

and all the network stuff is running in a separate thread but, some part of

>> the code needs to wait for any kynd of host response; when I do this all
>> the
>> OpenOffice.org ui hangs.
>>
>> I'm looking for some function cal to keep the UI responsive even if the
>> starbasic script is waiting; something like the gtk_main_iteration() call.
>>
>
> although I don't know what could be called in C++ or UNO to
> achive this, it may also help you to get some Basic related
> information. It's also possible to send Basic into a waiting
> loop that keeps the UI responsive by using the wait command,
> e.g.:
>
> sub main
>    while true
>        wait 1000       ' 1000 ms = 1 s
>        print "Hello"
>    wend
> end sub
>
> The UI is responsive while running this program. Instead of the
> print command you could call your extension to ask if there was
> a host response or a failure or whatever and then exit the loop.
>


--
Perry Werneck
Brasília - DF

Stephen Leacock<http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html>
- "I detest life-insurance agents: they always argue that I shall some
day
die, which is not so."