synchronized return from asynchronous message block

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

synchronized return from asynchronous message block

Peter Uhnak
Hi,

is it possible to return "synchronously" even if I have an asynchronous message?

For example:

SomeObject>>someMethod
        ^ UIManager default chooseFrom: #(a b c)

When the above method is executed, it will open a popup and block the execution until I select something, then it will return the selection.

But if I instead have something like this

SomeObject>>otherMethod
        |choice|
        NewListModel new
                items: #(a b c);
                whenSelectedItemChanged: [ :item | choice := item ];
                        openDialogWithSpec.
                        choice.

Then it will open the window but it will immediately return nil.

So my question is: is it possible to synchronously return even in the second example / block the flow until a selection is made?

Thanks,
Peter

Reply | Threaded
Open this post in threaded view
|

Re: synchronized return from asynchronous message block

Nicolai Hess-3-2


2016-06-07 8:21 GMT+02:00 Peter Uhnak <[hidden email]>:
Hi,

is it possible to return "synchronously" even if I have an asynchronous message?

For example:

SomeObject>>someMethod
        ^ UIManager default chooseFrom: #(a b c)

When the above method is executed, it will open a popup and block the execution until I select something, then it will return the selection.

But if I instead have something like this

SomeObject>>otherMethod
        |choice|
        NewListModel new
                items: #(a b c);
                whenSelectedItemChanged: [ :item | choice := item ];
                        openDialogWithSpec.
                        choice.

Then it will open the window but it will immediately return nil.


With a spec window, you can try to open it modal
WindowModel>>#modalRelativeTo: aWindow



So my question is: is it possible to synchronously return even in the second example / block the flow until a selection is made?

Thanks,
Peter


Reply | Threaded
Open this post in threaded view
|

Re: synchronized return from asynchronous message block

Peter Uhnak


On Tue, Jun 7, 2016 at 8:55 AM, Nicolai Hess <[hidden email]> wrote:


2016-06-07 8:21 GMT+02:00 Peter Uhnak <[hidden email]>:
Hi,

is it possible to return "synchronously" even if I have an asynchronous message?

For example:

SomeObject>>someMethod
        ^ UIManager default chooseFrom: #(a b c)

When the above method is executed, it will open a popup and block the execution until I select something, then it will return the selection.

But if I instead have something like this

SomeObject>>otherMethod
        |choice|
        NewListModel new
                items: #(a b c);
                whenSelectedItemChanged: [ :item | choice := item ];
                        openDialogWithSpec.
                        choice.

Then it will open the window but it will immediately return nil.


With a spec window, you can try to open it modal
WindowModel>>#modalRelativeTo: aWindow


NewListModel new ... openDialogWithSpec modalRelativeTo: self currentWorld.

Thanks!

Peter