public TPLMessageQueue(Action <Byte[]> receiveAction, CancellationToken?cancellationToken) : base(receiveAction, cancellationToken) { Messages = new ActionBlock <Byte[]>((message) => { // ToDO: Wrap in try catch and/or Polly ReceiveAction.Invoke(message); }); }
public void Datahandle(byte[] bytes) { BaseNetObject bno = NetBaseTool.BytesToObject(bytes) as BaseNetObject; if (bno is SystemNetObject) { SystemNetObject systemNetObject = bno as SystemNetObject; if (systemNetObject.GetType() == typeof(Msg)) { Console.WriteLine(systemNetObject); } else if (systemNetObject.GetType() == typeof(GetMyUserData)) { MyUserData = (systemNetObject as GetMyUserData).userData; } else if (systemNetObject.GetType() == typeof(CreateRoomS2C)) { transmit = (systemNetObject as CreateRoomS2C).PlayerId; wait.Set(); } else if (systemNetObject.GetType() == typeof(JoinRoomS2C)) { transmit = (systemNetObject as JoinRoomS2C); wait.Set(); } else if (systemNetObject.GetType() == typeof(GetRoomListS2C)) { transmit = (systemNetObject as GetRoomListS2C).rooms; wait.Set(); } else if (systemNetObject.GetType() == typeof(PlayerJoinS2C)) { PlayerJoin?.Invoke((systemNetObject as PlayerJoinS2C).playerId); } else if (systemNetObject.GetType() == typeof(PlayerLeaveS2C)) { PlayerLeave?.Invoke((systemNetObject as PlayerLeaveS2C).playerId); } else if (systemNetObject.GetType() == typeof(GameStart)) { StartAction?.Invoke(); } } else { GameNetObject gno = bno as GameNetObject; if (gno == null) { throw new ArgumentException(bno.GetType() + " Can't Used"); } ReceiveAction?.Invoke(gno); } //防止死锁 // wait.Set(); }
/// <summary> /// Remueve todos los items del mapa /// </summary> private void RemoveAllPins() { Action = Action.RemoveAllPins; ReceiveAction?.Invoke(this, null); }
public void ZoomForAllPins() { Action = Action.ZoomForAllPins; ReceiveAction?.Invoke(this, null); }
/// <summary> /// Agrega un pin /// </summary> /// <param name="pin"></param> private void AddPin(Pin pin) { Action = Action.AddPin; ReceiveAction?.Invoke(this, pin); }
/// <summary> /// Permite asignar el centro del mapa /// </summary> /// <param name="center"></param> public void SetCenter(Center center) { Action = Action.SetCenter; ReceiveAction?.Invoke(this, center); }
public void handleaction(string Action) { bool OKPressed = false; switch (Action) { case "Cancel": NewEntry = true; break; case "BackSpace": if (!NewEntry) { textBoxNumPadDisplay.Text = textBoxNumPadDisplay.Text.Substring(0, textBoxNumPadDisplay.Text.Length - 1); if (textBoxNumPadDisplay.Text == "") { NewEntry = true; } } break; case "Dot": if (NewEntry) { textBoxNumPadDisplay.Text = ""; NewEntry = false; } if (!textBoxNumPadDisplay.Text.Contains(decimalStr)) { textBoxNumPadDisplay.AppendText(decimalStr); } break; case "OK": if (textBoxNumPadDisplay.Text == decimalStr) { ReturnNumber = 0; } else { try { ReturnNumber = Math.Round(Convert.ToDouble(textBoxNumPadDisplay.Text), RoundingPrecision + 2, MidpointRounding.AwayFromZero); } catch { } } textBoxNumPadDisplay.Text = string.Format("{0:" + AMOUNT_FORMAT + "}", ReturnNumber); NewEntry = true; OKPressed = true; receiveAction.Invoke(); break; default: if (NewEntry) { textBoxNumPadDisplay.Text = ""; } textBoxNumPadDisplay.AppendText(Action); NewEntry = false; break; } if (OKPressed) { OKPressed = false; } else if (NewEntry) { textBoxNumPadDisplay.Text = 0.ToString(AMOUNT_FORMAT); } }