Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [platform-swt-dev] AsyncExec() problem ?

if you do it outside the !display.readanddispatch it seems to work.

I wish I knew exactly why, but that's what I managed to get happening,
through trial and error.

Will look again at home, for exactly what I did, but that's the basic jist
of it.





-----Original Message-----
From: platform-swt-dev-admin@xxxxxxxxxxx
[mailto:platform-swt-dev-admin@xxxxxxxxxxx]On Behalf Of Sylvain Becker
Sent: Friday, 31 October 2003 1:35 PM
To: platform-swt-dev@xxxxxxxxxxx
Subject: RE: [platform-swt-dev] AsyncExec() problem ?


Yes I have this thing too.
but, if you do this you need to move the mouse so that the windows is redraw
correctly, isn t??

I think, if you want to update, just do in your thread :


display.asyncExec( new Runnable() {
		public void run() {
			//update whatever widget you want
		}
});

--
Sylvain Becker


-----Original Message-----
From: platform-swt-dev-admin@xxxxxxxxxxx
[mailto:platform-swt-dev-admin@xxxxxxxxxxx]On Behalf Of Steve Vanspall
Sent: Thursday, October 30, 2003 5:55 PM
To: platform-swt-dev@xxxxxxxxxxx
Subject: RE: [platform-swt-dev] AsyncExec() problem ?


Sorry I wasn't intending to pry into the working of you app

Let me explain what I was trying to do, and hopefully it may have
application to your program.

I am building a Media Player which, for this version of it, it is acting as
a front end to a command line player that I have.

As you play an mp3 file with the command line player, it outputs a stream of
details pertaining to what frame it is up to in the mp3.

I wanted to take this information in and update a scale widget, to act as a
progress indicator. Because this input needs to be taken in constantly, I
was faced with the same problem.

My solution was to create a Thread, separately, whose only purpose was to
read the input and update an int variable, that was the current frame
number. then I got the asynch runnable to run when it could, and update that
value. This, at least for my needs, gave the veneer of being continuous.

it goes something like this.

Thread thread = new Thread(new Runnable(){
//read input from external process
//update frame number
//sleep for 100 milliseconds
});
thread.start();


then I did this in the !shell.isdisposed() loop

while(!shell.isDisposed())
{
	if(playing)
{
	display.asynchExec(Runnable(){
	//update progress indicator according to frame number
}

if(!display.readanddispatch())
	display.sleep();
}

Not sure if this means anything to you, but it's how I got around it.

Hopefully there will be a fix soon

Regards

Steve

-----Original Message-----
From: platform-swt-dev-admin@xxxxxxxxxxx
[mailto:platform-swt-dev-admin@xxxxxxxxxxx]On Behalf Of Sylvain Becker
Sent: Friday, 31 October 2003 12:15 PM
To: platform-swt-dev@xxxxxxxxxxx
Subject: RE: [platform-swt-dev] AsyncExec() problem ?


well, I would have prefered not to be really precisse.
I just wanted to signal the bug, or to be corrected if I used badly the
function.


for more detail regarding what I do :

I have a GUI, which is an "observer", et regarding the event received, with
the update function inherited for "observer", the GUI updated (lots of
label.setText(....)).

the Thread is the "observable" and with an infinite loop generate some
messages to update the GUI. (in fact, the thread reads some data from an
extern Target...)

..
At the begining I wanted juste tu use : display.asynchExec(thread). but as I
explain in my first mail, it freeze the GUI and make it unusable.
The solution I find is to create the tread with ( new Thread(..).start() )
and to keep it as an observable.
And when the update() function of the observer is called, I put the
display.asyncExec( new Runnable(){void run(){ label.setText() }})

--
Sylvain Becker

-----Original Message-----
From: platform-swt-dev-admin@xxxxxxxxxxx
[mailto:platform-swt-dev-admin@xxxxxxxxxxx]On Behalf Of Steve Vanspall
Sent: Thursday, October 30, 2003 3:59 PM
To: platform-swt-dev@xxxxxxxxxxx
Subject: RE: [platform-swt-dev] AsyncExec() problem ?


I found the same problem. Unfortunately in the end I just worked with it.

I did find if I remeber correctly that synch worked a bit better. I use it
to update a Scale widget when playing a sound file.

Don't have the code here at work, but will look at it again and confirm with
you.

But I never got to a point where the two ran truly in parallel. Whether this
in an SWT bug or a Native System issue, I am not sure.

What is it you are trying to update in the asynch thread?

Steve

-----Original Message-----
From: platform-swt-dev-admin@xxxxxxxxxxx
[mailto:platform-swt-dev-admin@xxxxxxxxxxx]On Behalf Of Sylvain Becker
Sent: Friday, 31 October 2003 10:29 AM
To: platform-swt-dev@xxxxxxxxxxx
Subject: [platform-swt-dev] AsyncExec() problem ?


Hi all,

I post here because I have some problems using the asyncExec() function of
the Display Class. And even after looking for many example, I think there
could be a problem with the function it self.

documentation says:

"Causes the run() method of the runnable to be invoked by the user-interface
thread at the next reasonable opportunity. The caller of this method
continues to run in parallel, and is not notified when the runnable has
completed."


but if I use something like this. the thread is called but is always on the
Top, so the GUI is updated, but never get the focus!!  the problem is
"caller of this method continues to run in parallel". in fact AsyncExec
seems to works like the "syncExec" function.

//set a thread to update the gui.
display.asyncExec( new Runnable() {
		public void run() {
			while(true) {
  				System.out.println("aa");
				//here, stuff to update the gui.
			}
		}
});


thanks you for your help,


--
Sylvain Becker

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top