How to return a value with Dispatcher.Invoke?

后端 未结 5 1983
执念已碎
执念已碎 2020-12-20 10:42

Anyone knows how to return a value from Dispatcher.Invoke in wpf? I want to return the selected index for a ComboBox.

Thanks!

5条回答
  •  情歌与酒
    2020-12-20 11:38

    You can't do this directly but you can do this.

    Dispatcher.Invoke() actually returns the return value from the delegate you call, so alter your delegate accordingly.

    Return Value

    Type: System.Object The return value from the delegate being invoked or null if the delegate has no return value.

    Source

提交回复
热议问题