mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
refactor: rewrite the way to make sure scan repositories panel shows at least 0.5s (#728)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
8342702103
commit
d3eca59036
1 changed files with 10 additions and 2 deletions
|
@ -1,7 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
|
||||||
namespace SourceGit.ViewModels
|
namespace SourceGit.ViewModels
|
||||||
|
@ -28,8 +30,8 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
// If it is too fast, the panel will disappear very quickly, then we'll have a bad experience.
|
var watch = new Stopwatch();
|
||||||
Task.Delay(500).Wait();
|
watch.Start();
|
||||||
|
|
||||||
var rootDir = new DirectoryInfo(RootDir);
|
var rootDir = new DirectoryInfo(RootDir);
|
||||||
var founded = new List<string>();
|
var founded = new List<string>();
|
||||||
|
@ -62,6 +64,12 @@ namespace SourceGit.ViewModels
|
||||||
Welcome.Instance.Refresh();
|
Welcome.Instance.Refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Make sure this task takes at least 0.5s to avoid that the popup panel do not disappear very quickly.
|
||||||
|
var remain = 500 - (int)watch.Elapsed.TotalMilliseconds;
|
||||||
|
watch.Stop();
|
||||||
|
if (remain > 0)
|
||||||
|
Task.Delay(remain).Wait();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue