Quantcast
Channel: radical Wiki Rss Feed
Viewing all articles
Browse latest Browse all 21

Updated Wiki: How to: handle the busy status during async/long running operations

$
0
0

Radical provides an overlay adorner to handle busy/long running operations, that for simple scenarios just works as expected. Sometimes there are cases when we need to handle a much more complex scenario such as the following:

As a user I want to be able to start a long running operation, and if, after a certain amount of time, the operation is not completed I want to be able to cancel the operation itself.

Let us start drawing the UI for the above requirements:

<AdornerDecorator><Gridbehaviors:BusyStatusManager.Status="{Binding Path=IsBusy, Converter={converters:BooleanBusyStatusConverter}}"><behaviors:BusyStatusManager.Content><Grid><Grid.RowDefinitions><RowDefinitionHeight="*"/><RowDefinitionHeight="*"/></Grid.RowDefinitions><Ellipsex:Name="ellipse"StrokeThickness="6"Width="30"Height="30"RenderTransformOrigin="0.5,0.5"><Ellipse.Resources><Storyboardx:Key="SpinAnimation"RepeatBehavior="Forever"><DoubleAnimationTo="359"Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"/></Storyboard></Ellipse.Resources><Ellipse.Triggers><EventTriggerRoutedEvent="FrameworkElement.Loaded"><BeginStoryboardStoryboard="{StaticResource SpinAnimation}"/></EventTrigger></Ellipse.Triggers><Ellipse.RenderTransform><TransformGroup><ScaleTransform/><SkewTransform/><RotateTransform/><TranslateTransform/></TransformGroup></Ellipse.RenderTransform><Ellipse.Stroke><LinearGradientBrushEndPoint="0.5,1"StartPoint="0.5,0"><GradientStopColor="Red"Offset="0"/><GradientStopColor="#FF1442BF"Offset="1"/></LinearGradientBrush></Ellipse.Stroke></Ellipse><ButtonIsEnabled="{Binding Path=ThresholdElapsed}"HorizontalAlignment="Center"VerticalAlignment="Top"Grid.Row="1"Content="Waited tooooo long, cancel..."Command="{markup:AutoCommandBinding Path=CancelWork}"/></Grid></behaviors:BusyStatusManager.Content><ButtonContent="Click me!"Command="{markup:AutoCommandBinding Path=WorkAsync}"HorizontalAlignment="Center"VerticalAlignment="Center"Width="70"Height="23"/></Grid></AdornerDecorator>

The above worker is tight to the sample and is not intended to be used in production.


Viewing all articles
Browse latest Browse all 21

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>