private void Dispatch(TcpClient client, CancellationToken token) { try { var bytes = new byte[65536]; using (var stream = client.GetStream()) while (true) { token.ThrowIfCancellationRequested(); stream.Read(bytes, 0, bytes.Length); _log.Debug("Message recieved"); var response = OnProcess?.Invoke(bytes); if (response != null) { stream.Write(response, 0, response.Length); } _log.Debug("Message sent"); } } catch (Exception e) { _log.Error(e); } finally { client.Close(); } }
private void Listen(CancellationToken token) { try { while (!token.IsCancellationRequested) { IPEndPoint endPoint = null; var request = _udp.Receive(ref endPoint); _log.Debug("Message recieved"); var response = OnProcess?.Invoke(request); if (response != null) { _udp.Send(response, response.Length, endPoint); } _log.Debug("Message sent"); } } catch (Exception e) { _log.Error(e); } finally { _udp.Close(); } }
protected override void OnShown(EventArgs e) { Task.Run( () => OnProcess?.Invoke(this, new EventArgs()), cancellationTokenSource.Token) .ContinueWith((t) => { if (t.Exception != null) { foreach (var exception in t.Exception.Flatten().InnerExceptions) { Console.Error.WriteLine(exception); } Console.Error.WriteLine("Search existing issues or create a new one here: https://github.com/SteamDatabase/ValveResourceFormat/issues"); SetProgress($"An exception occured, view console tab for more information. ({t.Exception.InnerException.Message})"); // TODO: Throwing doesn't actually display the exception ui throw t.Exception; } if (!t.IsCanceled) { Invoke((Action)Close); } }); }
public async Task ProcessMessage(TestDelayOutboxCommand message, CancellationToken cancellationToken) { Console.WriteLine($"TestCommandHandler - Processed command at {DateTime.Now}, Args: {message.Args}"); await Task.Delay(message.DelayMsec, cancellationToken); OnProcess?.Invoke(this, message); }
public void ProcessTurn() { OnProcess?.Invoke(); if (actionAgentList.Count > 0) { if (actionAgentList[0] == Player) { OnPlayerActionRequest?.Invoke(); actionAgentList.Remove(Player); } else { int enemyIndex = (int)actionAgentList[0]; BattleFactors monsterBF = MonsterBattleFactors[enemyIndex]; BattleFactors playerBF = Player.BattleFactors; PlayerSkillEffectStatuses.ForEach(x => x.effector.Use(playerBF, null)); if (HitCheck(monsterBF, playerBF)) { Skill skill = Monsters[enemyIndex].Action(); if (skill == null) { Player.AbilityFactors.HP -= Math.Max(monsterBF.physicalAttackPoint - playerBF.physicalDefencePoint, 1); } else { skill.Use(monsterBF, new List <BattleFactors> { playerBF }); skill.SkillEffectors.OfType <SustainSkillEffector>().ToList().ForEach(x => { SkillEffectStatus status = new SkillEffectStatus { effector = x, remainedRound = x.SustainRound }; if (x is TargetSpeedPointSkillEffector || x is TargetStopActionSkillEffector) { PlayerSkillEffectStatuses.Add(status); } else { MonstersSkillEffectStatuses[enemyIndex].Add(status); } }); } } else { OnMiss?.Invoke(true, enemyIndex); } ProcessTurn(); } } else { EndTurn(); } }
public async Task ProcessMessage(TestOutboxCommand message, CancellationToken cancellationToken) { //Console.WriteLine($"TestCommandHandler - Processing command at {DateTime.Now}, Args: {message.Args}"); await Task.Delay(2_000, cancellationToken); Console.WriteLine($"TestCommandHandler - Processed command at {DateTime.Now}, Args: {message.Args}"); OnProcess?.Invoke(this, EventArgs.Empty); }
private void ProcessInvoke(TransmissionPayload payload) { try { OnProcess?.Invoke(this, payload); } catch (Exception ex) { Collector?.LogException("ManualChannelSender/ProcessInvoke", ex); } }
protected override void OnShown(EventArgs e) { Task.Run( () => OnProcess?.Invoke(this, new EventArgs()), cancellationTokenSource.Token) .ContinueWith((t) => { if (!t.IsCanceled) { Invoke((Action)Close); } }); }
public void Listen() { while (_listener.IsListening) { var result = _listener.BeginGetContext(ar => { var listener = ar.AsyncState as HttpListener; var context = listener?.EndGetContext(ar); OnProcess?.Invoke(context); }, _listener); result.AsyncWaitHandle.WaitOne(); } }
public async Task <IEnumerable <string> > ProcessMultipleMessages(int numOfTasksToRun = 1) { // Console.WriteLine(messageQueue.Count); OnProcess?.Invoke(messageQueue.Count.ToString()); List <Task <string> > listTask = new List <Task <string> >(); for (int i = 0; i < numOfTasksToRun; i++) { listTask.Add(Task.Run(ProcessOneMessage)); } var results = await Task.WhenAll(listTask.ToArray()); return(results); }
public Task ProcessMessage(TestErrorOutboxCommand message, CancellationToken cancellationToken) { _count++; Console.WriteLine($"Try processed command at {DateTime.Now}, Count: {message.CountDown}"); if (message.CountDown > _count) { throw new InvalidDataException(); } Console.WriteLine($"Processed command at {DateTime.Now}, Count: {message.CountDown}"); OnProcess?.Invoke(this, EventArgs.Empty); return(Task.CompletedTask); }
public static void CallProcess(string message, Server.Connection connection) { OnProcess?.Invoke(message, connection); PacketBase pkt = StringToPacket(message); if (pkt == null) { return; } if (tcpProcessors.ContainsKey(pkt.t)) { tcpProcessors[pkt.t]?.Invoke(pkt, connection); } if (tcpIdProcessors.ContainsKey(connection.NetId)) { tcpIdProcessors[connection.NetId]?.Invoke(pkt, connection); } }
public async Task <Device> GetDevice(string address) { OVERRIDE_ONPROCESSEVENT = true; OnProcess?.Invoke(true); var name = await GetProp(address, "ro.product.model"); if (string.IsNullOrWhiteSpace(name)) { name = await GetProp(address, "ro.product.brand"); } if (string.IsNullOrWhiteSpace(name)) { name = await GetProp(address, "ro.product.device"); } if (string.IsNullOrWhiteSpace(name)) { name = "Unknown"; } var android = await GetProp(address, "ro.build.version.release"); if (string.IsNullOrWhiteSpace(android)) { android = "Unknown"; } var sdk = await GetProp(address, "ro.build.version.sdk"); int.TryParse(sdk, out int _sdk); var _abi = await GetProp(address, "ro.product.cpu.abi"); OnProcess?.Invoke(false); OVERRIDE_ONPROCESSEVENT = false; return(new Device() { Name = name, Android = android, Sdk = _sdk, Abi = _abi }); }
protected override void OnShown(EventArgs e) { Task.Run( () => OnProcess?.Invoke(this, new EventArgs()), cancellationTokenSource.Token) .ContinueWith((t) => { if (t.Exception != null) { Console.Error.WriteLine(t.Exception); SetProgress(t.Exception.Message); // TODO: Throwing doesn't actually display the exception ui throw t.Exception; } if (!t.IsCanceled) { Invoke((Action)Close); } }); }
public Task ProcessMessage(TestOutboxCommand message, CancellationToken cancellationToken) { Console.WriteLine($"TestCommandHandler - Processed command at {DateTime.Now}, Args: {message.Args}"); OnProcess?.Invoke(this, message); return(Task.CompletedTask); }
public override void Process(TRow row) { InvokeBeforeTargetAdapterProcessRowEvent(row); OnProcess?.Invoke(this, row); InvokeAfterTargetAdapterProcessRowEvent(row); }
protected void OnProcessAction(ProcessEventArgs e) { OnProcess?.Invoke(this, e); }
private async Task <string> RunAsync(string command, params object[] args) { using (var p = new Process()) { var OutputMessage = string.Empty; p.OutputDataReceived += (s, e) => { if (string.IsNullOrWhiteSpace(e.Data)) { return; } OutputMessage += e.Data + Environment.NewLine; if (!OVERRIDE_ONREPORTEVENT) { OutputDataReceived?.Invoke(e.Data); } }; var ErrorMessage = string.Empty; p.ErrorDataReceived += (s, e) => { if (string.IsNullOrWhiteSpace(e.Data)) { return; } ErrorMessage += e.Data + Environment.NewLine; if (!OVERRIDE_ONREPORTEVENT) { ErrorDataReceived?.Invoke(e.Data); } }; p.StartInfo = new ProcessStartInfo() { UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, WindowStyle = ProcessWindowStyle.Hidden, FileName = Path.Combine("Lib", "adb.exe"), Arguments = string.Format(command, args) }; p.Start(); Debug.Print("Adb.Command: adb {0}", string.Format(command, args)); if (!OVERRIDE_ONPROCESSEVENT) { OnProcess?.Invoke(true); } p.BeginOutputReadLine(); p.BeginErrorReadLine(); await Task.Run(() => p.WaitForExit()); if (!OVERRIDE_ONPROCESSEVENT) { OnProcess?.Invoke(false); } if (p.ExitCode != 0) { throw new Exception(ErrorMessage); } Debug.Print("Adb.Output: {0}", OutputMessage); return(OutputMessage); }; }
public override void _Process(float delta) => OnProcess?.Invoke(this, delta);
public void Invoke() { OnProcess?.Invoke(); }
public override void Process() { OnProcess?.Invoke(Manager); }
public void SeOnProcess(int percent, string itemDescription, bool showProgress = true) { OnProcess?.Invoke(this, new ProcessArgs(percent, "", itemDescription, showProgress)); }
/// <summary> /// Lanza el evento de procesado /// </summary> /// <param name="state">Estado</param> protected void RaiseOnProcess(EProcessState state) { OnProcess?.Invoke(this, state); }
public virtual void Process(TEntity instance) { OnProcess?.Invoke(instance); }