private static async Task MainAsync() { var filePipe = new FilePipe( Container.Resolve <IConfig>(), Container.Resolve <IResultFactory>(), ExitToken.Token); var metadataPipe = new MetadataPipe( Container.Resolve <IConfig>(), Container.Resolve <IResultFactory>(), filePipe); var transferPipe = new TransferPipe( Container.Resolve <IConfig>(), Container.Resolve <IResultFactory>(), metadataPipe); var cancelSource = new CancellationTokenSource(); var ui = Task.Run(() => ReportStatus(Container.Resolve <IResultFactory>(), filePipe, metadataPipe, transferPipe, cancelSource.Token)); await Task.WhenAll(filePipe.Execute(), metadataPipe.Execute(), transferPipe.Execute()); cancelSource.Cancel(); await ui; var results = Container.Resolve <IResultFactory>(); Console.WriteLine("Complete. Writing index file."); results.WriteFile(); }
public async void ShouldDiscoverNestedFiles() { //Arrange var config = ReusableMocks.MockConfig(); var nestedFolder = Path.Combine(config.Src, Guid.NewGuid().ToString("N")); Directory.CreateDirectory(nestedFolder); var file = TestUtilities.CreateFile(config.Src, "Example1.doc", DateTime.Now.Add(config.CurrentTimespan).AddDays(-1)); var nestedFile = TestUtilities.CreateFile(nestedFolder, "Example2.doc", DateTime.Now.Add(config.CurrentTimespan).AddDays(-1)); var token = new CancellationTokenSource(); var pipe = new FilePipe( config, ReusableMocks.MockResultFactory(), token.Token); //Act await pipe.Execute(); //Assert Assert.That(pipe.Buffer.Count == 2); }
public Form1() { InitializeComponent(); V = this; m_log = new Queue <string>(); FilePipe.Log = (s) => { lock (m_log) { m_log.Enqueue(s); } }; m_pipe = new FilePipe("mon"); m_pipe.Start(); }
public MemoryServiceChannel(string name, bool biDirectional, MscMode mode, int ttl, IIdentityProvider userProvider) { Name = name; this.mode = mode; this.ttl = ttl; this.userProvider = userProvider; src = new CancellationTokenSource(); endTok = src.Token; string incomingName = string.Empty, outgoingName = string.Empty; if (mode == MscMode.Client) { if (biDirectional) { incomingName = string.Format(clientChannel, name); } outgoingName = string.Format(serverChannel, name); } else { if (biDirectional) { outgoingName = string.Format(clientChannel, name); } incomingName = string.Format(serverChannel, name); } if (!string.IsNullOrEmpty(incomingName)) { incoming = new FilePipe(incomingName); incoming.DataReceived += IncomingData; incoming.Listen(); } if (!string.IsNullOrEmpty(outgoingName)) { outgoing = new FilePipe(outgoingName); } connected = true; Connected = true; }
public void Start() { //Log("netcomm:start"); m_bReqAbort = false; m_bEnd = false; m_mtx = new object(); m_pipe = new FilePipe(m_myname); m_pipe.Start(); m_sendlog = new Queue <string>(); m_thread = new Thread(Work); m_thread.IsBackground = true; m_thread.Priority = ThreadPriority.AboveNormal; m_thread.Start(); slagtool.util.SetRemoteLogFunc(wk.SendWriteLine, wk.SendWrite); }
public bool IsEnd() { if (m_pipe != null) { if (m_pipe.IsEnd()) { m_bReqAbort = true; m_pipe = null; } return(false); } if (m_bEnd && m_thread != null) { m_thread.Join(); m_thread = null; return(false); } return(m_bEnd); }
public void Dispose() { if (!disposed) { try { var t = waitingOperations.Keys.ToArray(); foreach (var key in t) { var ok = waitingOperations.TryRemove(key, out var op); if (!op.ServerResponse.Task.IsCompleted) { op.ServerResponse.SetException(new Exception("Service is shutting down.")); } } src?.Cancel(); src?.Dispose(); if (incoming != null) { incoming.DataReceived -= IncomingData; incoming.Dispose(); } outgoing?.Dispose(); src = null; incoming = null; outgoing = null; } catch (Exception ex) { LogEnvironment.LogEvent($"Error disconnecting: {ex.OutlineException()}", LogSeverity.Error); } finally { disposed = true; } } }