| [DataBinding] SWT Event Dispatch Thread Synchronization for TextObservableValue - gone? [message #447686] |
Wed, 12 April 2006 12:40  |
Eclipse User |
|
|
|
As it seems the synchronized access for widgets using the previously
available SyncRunnable/AsyncRunnable classes is no longer implemented.
Therefore the application code is now responsible for a correct behavior
(i.e. the model may only be updated in the event dispatch thread to
avoid invalid thread access exceptions).
Will this behavior remain in the future of the databinding and do I
therefore don't have to implement synchronization code within my own UI
based Observables?
Thank you for your suggestions
Rainer
Code taken from the outdated TextUpdatableValue:
......
public void setValue(final Object value) {
AsyncRunnable runnable = new AsyncRunnable(){
public void run(){
String oldValue = text.getText();
try {
updating = true;
bufferedValue = (String)value;
text.setText(value == null ? "" : value.toString());
} finally {
updating = false;
}
fireChangeEvent(ChangeEvent.CHANGE, oldValue, text.getText());
}
};
runnable.runOn(text.getDisplay());
}
public Object computeValue() {
SyncRunnable runnable = new SyncRunnable(){
public Object run() {
return text.getText();
}
};
return runnable.runOn(text.getDisplay());
}
|
|
|
|
| Re: [DataBinding] SWT Event Dispatch Thread Synchronization for TextObservableValue - gone? [message #448238 is a reply to message #447775] |
Wed, 19 April 2006 13:45  |
Eclipse User |
|
|
|
Yes, thank you for the explanation.
Kind regards, Rainer
David J. Orme wrote:
> We had removed this code because we realized that our thread
> synchronization story was broken. We would automatically synchronize
> with the UI thread if some other thread called us, but we had/have no
> way to synchronize with the other thread when we need to call to an
> Observable that wants to run on another thread.
>
> So our current threading story is that we only support running on the UI
> thread if you're binding to SWT and that your code needs to synchronize
> with the UI thread before calling us.
>
> We know that stinks. But there wasn't time before API freeze in M5 to
> think of anything better. Which is why we decided to release as
> provisional API--so we could fix this when we get feedback about what
> works and what doesn't from other folks who are using data binding.
>
> Hope this helps!
>
>
> Best regards,
>
> Dave Orme
>
> Rainer Lang wrote:
>> As it seems the synchronized access for widgets using the previously
>> available SyncRunnable/AsyncRunnable classes is no longer implemented.
>> Therefore the application code is now responsible for a correct
>> behavior (i.e. the model may only be updated in the event dispatch
>> thread to avoid invalid thread access exceptions).
>>
>> Will this behavior remain in the future of the databinding and do I
>> therefore don't have to implement synchronization code within my own
>> UI based Observables?
>>
>> Thank you for your suggestions
>> Rainer
>>
>>
>> Code taken from the outdated TextUpdatableValue:
>> .....
>>
>> public void setValue(final Object value) {
>>
>> AsyncRunnable runnable = new AsyncRunnable(){
>> public void run(){
>> String oldValue = text.getText();
>> try {
>> updating = true;
>> bufferedValue = (String)value;
>> text.setText(value == null ? "" : value.toString());
>> } finally {
>> updating = false;
>> }
>> fireChangeEvent(ChangeEvent.CHANGE, oldValue, text.getText());
>> }
>> };
>> runnable.runOn(text.getDisplay());
>> }
>>
>> public Object computeValue() {
>> SyncRunnable runnable = new SyncRunnable(){
>> public Object run() {
>> return text.getText();
>> }
>> };
>> return runnable.runOn(text.getDisplay());
>> }
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02845 seconds