Reputation: 145
private void Module_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
// new SolidColorBrush(Color.FromArgb(32, 0, 0, 0)) belongs to black color
LayoutRoot.OpacityMask = new SolidColorBrush(Color.FromArgb(32, 0, 0, 0));
// Some code over here...
}
First statement is to update the OpacityMask of grid named LayoutRoot.
Here code after first statement is a large process which will take around one minute or more to execute.
But opacity mask only changes background i.e. opacity of page after one minute once this event executed.enter code here
Please help me so that opacity mask could be run, before that long code which will take around 1 or more minutes to execute.
Upvotes: 2
Views: 209
Reputation: 128013
The code in your event handler method blocks the UI thread.
Declare the handler method async, and call the long running code in a Task Action:
private async void Module_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
LayoutRoot.Opacity = 0.125;
await Task.Run(() =>
{
// long running code...
});
LayoutRoot.Opacity = 1;
}
Upvotes: 2