Files
speckle.xunit.runner.wpf/xunit.runner.wpf/Impl/RemoteTestUtil .BackgroundRunner.cs
T
Jared Parsons 99bbd2c2c9 Remote execution from the UI
The UI now executes the tests in a separate process.  This removes the
need to shadow copy and frees up the idea of re-running the tests
without restart of the UI.
2015-08-19 12:58:57 -07:00

59 lines
1.6 KiB
C#

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using xunit.runner.data;
using xunit.runner.wpf.ViewModel;
namespace xunit.runner.wpf.Impl
{
internal partial class RemoteTestUtil
{
private sealed class BackgroundRunner
{
private readonly ConcurrentQueue<TestResultData> _resultQueue;
private readonly BinaryReader _reader;
internal BackgroundRunner(ConcurrentQueue<TestResultData> resultQueue, BinaryReader reader)
{
_resultQueue = resultQueue;
_reader = reader;
}
/// <summary>
/// This will be called on a background thread to read the results of the test from the
/// named pipe client stream.
/// </summary>
/// <returns></returns>
internal Task GoOnBackground()
{
while (true)
{
TestResultData result;
try
{
result = TestResultData.ReadFrom(_reader);
}
catch
{
// Hacky way of detecting the stream being closed
break;
}
_resultQueue.Enqueue(result);
}
// Signal we are done
_resultQueue.Enqueue(null);
return Task.FromResult(true);
}
}
}
}