static async Task Run(IEchoer echoer) { var payload = new byte[20]; new Random().NextBytes(payload); #if SOTASK_PERF int counter = 0; #endif while (true) { var result = await echoer.Echo(payload); if (result.Count != payload.Length) { throw new InvalidOperationException("Echo server malfunction"); } #if SOTASK_PERF if (++counter == 10000) { counter = 0; Console.WriteLine($"StrictlyOrderedTask performance statistics:"); Console.WriteLine($"AwaitInternal: max. {Capnp.Util.StrictlyOrderedTaskExtensions.Stats.AwaitInternalMaxOuterIterations} outer iterations"); Console.WriteLine($"AwaitInternal: max. {Capnp.Util.StrictlyOrderedTaskExtensions.Stats.AwaitInternalMaxInnerIterations} inner iterations"); Console.WriteLine($"OnCompleted: max. {Capnp.Util.StrictlyOrderedTaskExtensions.Stats.OnCompletedMaxSpins} iterations"); } #endif } }
public void Setup() { _client = new TcpRpcClient("localhost", 5002); if (BufferSize > 0) { _client.AddBuffering(BufferSize); } _client.WhenConnected.Wait(); _echoer = _client.GetMain <IEchoer>(); _payload = new byte[PayloadBytes]; new Random().NextBytes(_payload); }
public MainForm(IAboutBox aboutBox, ILogger logger, IEchoer echoer, IFileSender fileSender, CurrentDataDevice dataDevice, WinformsMainMenuExtender mainMenuExtender, IEnumerable<IStatusbarExtension> statusbarExtensions) { _aboutBox = aboutBox; _logger = logger; _echoer = echoer; _fileSender = fileSender; _mainMenuExtender = mainMenuExtender; _statusbarExtensions = statusbarExtensions; _currentDataDevice = dataDevice; _currentDataDevice.PropertyChanged += (sender, args) => { var oldDataDevice = _dataDevice; _dataDevice = _currentDataDevice.CurrentDevice; if (_dataDevice != null) { _dataDevice.PropertyChanged += DataDeviceOnPropertyChanged; _dataDevice.DataReceived += DataDeviceOnDataReceived; } if (oldDataDevice != null) { oldDataDevice.PropertyChanged -= DataDeviceOnPropertyChanged; oldDataDevice.DataReceived -= DataDeviceOnDataReceived; } }; _dataDevice = _currentDataDevice.CurrentDevice; Log.Debug("Mainform object created"); }
/// <summary> /// Default Constructor /// </summary> /// <param name="config">Configuration Values</param> public Synchronizer(IConfigValues config) { if (null == config) { throw new ArgumentNullException("config"); } if (null == config.Source) { throw new ArgumentNullException("source"); } if (null == config.Destination) { throw new ArgumentNullException("destination"); } if (Direction.Unknown == config.Direction) { throw new ArgumentException("Invalid Direction."); } switch (config.Direction) { case Direction.BlobToBlob: this.lister = new BlobReader(config.Source.ContainerName, config.Source.ConnectionString); this.writer = new BlobWriter(config.Destination.ContainerName, config.Destination.ConnectionString, config.CreateSnapshot); break; case Direction.BlobToFolder: this.lister = new BlobReader(config.Source.ContainerName, config.Source.ConnectionString); this.writer = new FolderWriter(config.Destination.Folder); break; case Direction.FolderToFolder: this.lister = new FolderReader(config.Source.Folder); this.writer = new FolderWriter(config.Destination.Folder); break; case Direction.FolderToBlob: this.lister = new FolderReader(config.Source.Folder); this.writer = new BlobWriter(config.Destination.ContainerName, config.Destination.ConnectionString); break; } if (config.Echo) { IDataLister echoLister = null; switch (config.Direction) { case Direction.FolderToBlob: case Direction.BlobToBlob: echoLister = new BlobReader(config.Destination.ContainerName, config.Destination.ConnectionString); break; case Direction.FolderToFolder: case Direction.BlobToFolder: echoLister = new FolderReader(config.Destination.Folder); break; } this.echoer = new Echoer(echoLister); } }