Windows 8. Metro app. XAML asynchronous binding

The problem is tying getter's long-term performance to user interface management. For example, if I have a property like:

public string ButtonText { get { Task.Delay(3000).Wait(); return _buttonText; } set { _buttonText = value; } } 

and bind it in the XAML control for the UI, for example: Content="{Binding ButtonText}" user interface thread will be blocked. WPF has a Binding.IsAsync property that allows you to load related data in the background, but there is no such property in the Metro structure.

Does anyone have any ideas on how I can create asynchronous input bindings in a metro application?

+4
source share
1 answer

Microsoft purposefully changed a bunch of these things to encourage you not to do something in your assets / setters that you need in order to get the async property. The β€œnew” way to not block the UI thread is to do something like await Task.Delay(3000) instead of using Binding.IsAsync . await blocks execution, but not a thread (exactly what you are trying to do).

Here is the page for more information on the await key in C # on .NET 4.5. The example at the bottom of the page gives a good idea of ​​what your code looks like.

http://msdn.microsoft.com/en-us/library/hh156528.aspx

-1
source

Source: https://habr.com/ru/post/1438473/


All Articles