Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creating a Task instance doesn't execute it #1997

Merged
merged 1 commit into from
Jun 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions MahApps.Metro/Controls/MetroWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -604,15 +604,19 @@ public System.Threading.Tasks.Task ShowOverlayAsync()
{
if (overlayBox == null) throw new InvalidOperationException("OverlayBox can not be founded in this MetroWindow's template. Are you calling this before the window has loaded?");

var tcs = new System.Threading.Tasks.TaskCompletionSource<object>();

if (IsOverlayVisible() && overlayStoryboard == null)
return new System.Threading.Tasks.Task(() => { }); //No Task.FromResult in .NET 4.
{
//No Task.FromResult in .NET 4.
tcs.SetResult(null);
return tcs.Task;
}

Dispatcher.VerifyAccess();

overlayBox.Visibility = Visibility.Visible;

var tcs = new System.Threading.Tasks.TaskCompletionSource<object>();

var sb = (Storyboard) this.Template.Resources["OverlayFastSemiFadeIn"];

sb = sb.Clone();
Expand Down Expand Up @@ -646,13 +650,17 @@ public System.Threading.Tasks.Task HideOverlayAsync()
{
if (overlayBox == null) throw new InvalidOperationException("OverlayBox can not be founded in this MetroWindow's template. Are you calling this before the window has loaded?");

var tcs = new System.Threading.Tasks.TaskCompletionSource<object>();

if (overlayBox.Visibility == Visibility.Visible && overlayBox.Opacity == 0.0)
return new System.Threading.Tasks.Task(() => { }); //No Task.FromResult in .NET 4.
{
//No Task.FromResult in .NET 4.
tcs.SetResult(null);
return tcs.Task;
}

Dispatcher.VerifyAccess();

var tcs = new System.Threading.Tasks.TaskCompletionSource<object>();

var sb = (Storyboard) this.Template.Resources["OverlayFastSemiFadeOut"];

sb = sb.Clone();
Expand Down