Skip to content

Commit

Permalink
keep UI responsive even if many text is logged
Browse files Browse the repository at this point in the history
  • Loading branch information
plainionist committed Aug 24, 2017
1 parent aef8d4e commit c3538f8
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 100 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.9 - 2017-08-24

- keep UI responsive even if many text is logged

## 1.8 - 2017-08-23

- fixed updating pending changes
Expand Down
8 changes: 4 additions & 4 deletions src/Plainion.CI.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
[assembly: AssemblyProductAttribute("Plainion.CI")]
[assembly: AssemblyDescriptionAttribute("Plainion.CI")]
[assembly: AssemblyCopyrightAttribute("Copyright @ 2017")]
[assembly: AssemblyVersionAttribute("1.8")]
[assembly: AssemblyFileVersionAttribute("1.8")]
[assembly: AssemblyVersionAttribute("1.9")]
[assembly: AssemblyFileVersionAttribute("1.9")]
namespace System {
internal static class AssemblyVersionInformation {
internal const System.String AssemblyTitle = "Plainion.CI.Core";
internal const System.String AssemblyProduct = "Plainion.CI";
internal const System.String AssemblyDescription = "Plainion.CI";
internal const System.String AssemblyCopyright = "Copyright @ 2017";
internal const System.String AssemblyVersion = "1.8";
internal const System.String AssemblyFileVersion = "1.8";
internal const System.String AssemblyVersion = "1.9";
internal const System.String AssemblyFileVersion = "1.9";
}
}
8 changes: 4 additions & 4 deletions src/Plainion.CI.Redist/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
[assembly: AssemblyProductAttribute("Plainion.CI")]
[assembly: AssemblyDescriptionAttribute("Plainion.CI")]
[assembly: AssemblyCopyrightAttribute("Copyright @ 2017")]
[assembly: AssemblyVersionAttribute("1.8")]
[assembly: AssemblyFileVersionAttribute("1.8")]
[assembly: AssemblyVersionAttribute("1.9")]
[assembly: AssemblyFileVersionAttribute("1.9")]
namespace System {
internal static class AssemblyVersionInformation {
internal const System.String AssemblyTitle = "Plainion.CI.Redist";
internal const System.String AssemblyProduct = "Plainion.CI";
internal const System.String AssemblyDescription = "Plainion.CI";
internal const System.String AssemblyCopyright = "Copyright @ 2017";
internal const System.String AssemblyVersion = "1.8";
internal const System.String AssemblyFileVersion = "1.8";
internal const System.String AssemblyVersion = "1.9";
internal const System.String AssemblyFileVersion = "1.9";
}
}
8 changes: 4 additions & 4 deletions src/Plainion.CI.Tasks/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Plainion.CI")>]
[<assembly: AssemblyDescriptionAttribute("Plainion.CI")>]
[<assembly: AssemblyCopyrightAttribute("Copyright @ 2017")>]
[<assembly: AssemblyVersionAttribute("1.8")>]
[<assembly: AssemblyFileVersionAttribute("1.8")>]
[<assembly: AssemblyVersionAttribute("1.9")>]
[<assembly: AssemblyFileVersionAttribute("1.9")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "Plainion.CI.Tasks"
let [<Literal>] AssemblyProduct = "Plainion.CI"
let [<Literal>] AssemblyDescription = "Plainion.CI"
let [<Literal>] AssemblyCopyright = "Copyright @ 2017"
let [<Literal>] AssemblyVersion = "1.8"
let [<Literal>] AssemblyFileVersion = "1.8"
let [<Literal>] AssemblyVersion = "1.9"
let [<Literal>] AssemblyFileVersion = "1.9"
8 changes: 4 additions & 4 deletions src/Plainion.CI.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
[assembly: AssemblyProductAttribute("Plainion.CI")]
[assembly: AssemblyDescriptionAttribute("Plainion.CI")]
[assembly: AssemblyCopyrightAttribute("Copyright @ 2017")]
[assembly: AssemblyVersionAttribute("1.8")]
[assembly: AssemblyFileVersionAttribute("1.8")]
[assembly: AssemblyVersionAttribute("1.9")]
[assembly: AssemblyFileVersionAttribute("1.9")]
namespace System {
internal static class AssemblyVersionInformation {
internal const System.String AssemblyTitle = "Plainion.CI.Tests";
internal const System.String AssemblyProduct = "Plainion.CI";
internal const System.String AssemblyDescription = "Plainion.CI";
internal const System.String AssemblyCopyright = "Copyright @ 2017";
internal const System.String AssemblyVersion = "1.8";
internal const System.String AssemblyFileVersion = "1.8";
internal const System.String AssemblyVersion = "1.9";
internal const System.String AssemblyFileVersion = "1.9";
}
}
8 changes: 4 additions & 4 deletions src/Plainion.CI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
[assembly: AssemblyProductAttribute("Plainion.CI")]
[assembly: AssemblyDescriptionAttribute("Plainion.CI")]
[assembly: AssemblyCopyrightAttribute("Copyright @ 2017")]
[assembly: AssemblyVersionAttribute("1.8")]
[assembly: AssemblyFileVersionAttribute("1.8")]
[assembly: AssemblyVersionAttribute("1.9")]
[assembly: AssemblyFileVersionAttribute("1.9")]
namespace System {
internal static class AssemblyVersionInformation {
internal const System.String AssemblyTitle = "Plainion.CI";
internal const System.String AssemblyProduct = "Plainion.CI";
internal const System.String AssemblyDescription = "Plainion.CI";
internal const System.String AssemblyCopyright = "Copyright @ 2017";
internal const System.String AssemblyVersion = "1.8";
internal const System.String AssemblyFileVersion = "1.8";
internal const System.String AssemblyVersion = "1.9";
internal const System.String AssemblyFileVersion = "1.9";
}
}
156 changes: 78 additions & 78 deletions src/Plainion.CI/Services/SourceControl/PendingChangesObserver.cs
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;

namespace Plainion.CI.Services.SourceControl
{
class PendingChangesObserver
{
private ISourceControl mySourceControl;
private Action<IEnumerable<Change>> myOnPendingChangesChanged;
private FileSystemWatcher myPendingChangesWatcher;
private string myWorkspaceRoot;
private Task myWorkspaceReaderTask;
namespace Plainion.CI.Services.SourceControl
{
class PendingChangesObserver
{
private ISourceControl mySourceControl;
private Action<IEnumerable<Change>> myOnPendingChangesChanged;
private FileSystemWatcher myPendingChangesWatcher;
private string myWorkspaceRoot;
private Task myWorkspaceReaderTask;
private bool myWorkspaceChanged;
private HashSet<Change> myCurrentPendingChanges;

public PendingChangesObserver(ISourceControl sourceControl, Action<IEnumerable<Change>> onPendingChangesChanged)
{
Contract.RequiresNotNull(sourceControl, "sourceControl");
Contract.RequiresNotNull(onPendingChangesChanged, "onPendingChangesChanged");

mySourceControl = sourceControl;
myOnPendingChangesChanged = onPendingChangesChanged;
myCurrentPendingChanges = new HashSet<Change>();
}

public void Start(string workspaceRoot)
{
Contract.Invariant(myPendingChangesWatcher == null, "Pending changes watcher still running");

myWorkspaceRoot = workspaceRoot;

myPendingChangesWatcher = new FileSystemWatcher();

myPendingChangesWatcher.Path = workspaceRoot;
myPendingChangesWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.DirectoryName;
myPendingChangesWatcher.Filter = "*";
myPendingChangesWatcher.IncludeSubdirectories = true;

myPendingChangesWatcher.Created += OnChanged;
myPendingChangesWatcher.Changed += OnChanged;
myPendingChangesWatcher.Deleted += OnChanged;
myPendingChangesWatcher.Renamed += OnChanged;

myPendingChangesWatcher.EnableRaisingEvents = true;

// run initial analysis
OnChanged(null, null);
}

private void OnChanged(object source, FileSystemEventArgs e)
{
Debug.WriteLine("Workspace change detected");

if (myWorkspaceReaderTask != null)
{
myWorkspaceChanged = true;
return;
}

myWorkspaceChanged = false;

myWorkspaceReaderTask = mySourceControl.GetPendingChangesAsync(myWorkspaceRoot)
public PendingChangesObserver(ISourceControl sourceControl, Action<IEnumerable<Change>> onPendingChangesChanged)
{
Contract.RequiresNotNull(sourceControl, "sourceControl");
Contract.RequiresNotNull(onPendingChangesChanged, "onPendingChangesChanged");

mySourceControl = sourceControl;
myOnPendingChangesChanged = onPendingChangesChanged;
myCurrentPendingChanges = new HashSet<Change>();
}

public void Start(string workspaceRoot)
{
Contract.Invariant(myPendingChangesWatcher == null, "Pending changes watcher still running");

myWorkspaceRoot = workspaceRoot;

myPendingChangesWatcher = new FileSystemWatcher();

myPendingChangesWatcher.Path = workspaceRoot;
myPendingChangesWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.DirectoryName;
myPendingChangesWatcher.Filter = "*";
myPendingChangesWatcher.IncludeSubdirectories = true;

myPendingChangesWatcher.Created += OnChanged;
myPendingChangesWatcher.Changed += OnChanged;
myPendingChangesWatcher.Deleted += OnChanged;
myPendingChangesWatcher.Renamed += OnChanged;

myPendingChangesWatcher.EnableRaisingEvents = true;

// run initial analysis
OnChanged(null, null);
}

private void OnChanged(object source, FileSystemEventArgs e)
{
Debug.WriteLine("Workspace change detected");

if (myWorkspaceReaderTask != null)
{
myWorkspaceChanged = true;
return;
}

myWorkspaceChanged = false;

myWorkspaceReaderTask = mySourceControl.GetPendingChangesAsync(myWorkspaceRoot)
.ContinueWith(t =>
{
// intentionally we ignore all exceptions here because if in parallel a checkin or push is running
Expand All @@ -77,7 +77,7 @@ private void OnChanged(object source, FileSystemEventArgs e)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() => PropagatePendingChnages(t.Result)));
}
})
})
.ContinueWith(t =>
{
myWorkspaceReaderTask = null;
Expand All @@ -86,9 +86,9 @@ private void OnChanged(object source, FileSystemEventArgs e)
{
OnChanged(null, null);
}
});
}

});
}

private void PropagatePendingChnages(IReadOnlyCollection<Change> changes)
{
if (myCurrentPendingChanges.SetEquals(changes))
Expand All @@ -101,15 +101,15 @@ private void PropagatePendingChnages(IReadOnlyCollection<Change> changes)
myCurrentPendingChanges = new HashSet<Change>(changes);

myOnPendingChangesChanged(myCurrentPendingChanges);
}

public void Stop()
{
if (myPendingChangesWatcher != null)
{
myPendingChangesWatcher.Dispose();
}
myWorkspaceReaderTask = null;
}
}
}
}

public void Stop()
{
if (myPendingChangesWatcher != null)
{
myPendingChangesWatcher.Dispose();
}
myWorkspaceReaderTask = null;
}
}
}
20 changes: 18 additions & 2 deletions src/Plainion.CI/ViewModels/BuildLogViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.ComponentModel.Composition;
using System;
using System.ComponentModel.Composition;
using System.Text;
using System.Windows;
using Plainion.Windows.Mvvm;

namespace Plainion.CI.ViewModels
Expand All @@ -9,6 +11,7 @@ class BuildLogViewModel : BindableBase
{
private StringBuilder myLog;
private bool? mySucceeded;
private bool myIsRefreshPending;

public BuildLogViewModel()
{
Expand All @@ -23,7 +26,20 @@ public string Log
public void Append(string line)
{
myLog.AppendLine(line);
OnPropertyChanged(nameof(Log));

if (myIsRefreshPending)
{
return;
}

myIsRefreshPending = true;

// keep UI responsive even if there is a lot of text logged
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
OnPropertyChanged(nameof(Log));
myIsRefreshPending = false;
}));
}

public void Clear()
Expand Down

0 comments on commit c3538f8

Please sign in to comment.