private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { ActivateMethod d = new ActivateMethod(ForceToFront); hasInvoked = true; while (true) { try { Thread.Sleep(500); if (hasInvoked) { d.BeginInvoke(new AsyncCallback(isFinished), null); hasInvoked = false; } } catch { } } }
public void SetSkillData(SkillData skillData) { this.skillData = skillData; ActivateMethod = ActivateMethod.Position; SkillImpactPrefab = skillData.SkillImpact.Asset as GameObject; SkillEffects = skillData.SkillEffect; switch (skillData.SkillImpact.Asset.GetComponent <SkillImpact>().ImpactType) { case ImpactType.Areal: case ImpactType.Collisional: case ImpactType.Penetrative: ActivateMethod = ActivateMethod.Direction; break; case ImpactType.Self: ActivateMethod = ActivateMethod.Local; break; case ImpactType.Targeted: ActivateMethod = ActivateMethod.TargetedEntity; break; } }
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e) { try { PipeSecurity ps = new PipeSecurity(); var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null); NTAccount account = (NTAccount)sid.Translate(typeof(NTAccount)); ps.SetAccessRule( new PipeAccessRule(account, PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow)); NamedPipeServerStream server = new NamedPipeServerStream("BLOCKMESSAGEPIPE", PipeDirection.InOut, 1, PipeTransmissionMode.Message, PipeOptions.None, 16384, 16384, ps); SetTextMethod setText = new SetTextMethod(SetText); ActivateMethod activator = new ActivateMethod(ForceToFront); while (true) { server.WaitForConnection(); TReceiver receiver = new TReceiver(server, server); byte[] data; int len = receiver.Receive(out data); if (len == -1) { server.Write( Encoding.UTF8.GetBytes("400 Invalid message"), 0, "400 Invalid message".Length); server.Disconnect(); continue; } TMessage msg = new TMessage(); msg.Process(data); string text = msg.Text; TResponse response = new TResponse(msg); switch (msg.Arguments[0].ToUpper()) { case "CLOSE": response.Process(202, "Exiting block message"); server.Write(response.Data, 0, response.Length); server.WaitForPipeDrain(); server.Disconnect(); server.Dispose(); return; case "SETTEXT": if (msg.Arguments.Length != 2) { response.Process(400, "Bad Request"); break; } Invoke(setText, msg.Arguments[1]); response.Process(200, "Text changed"); break; case "GETTEXT": response.Process(200, label1.Text); break; case "ACTIVATE": Invoke(activator); response.Process(200, "Activated"); break; default: response.Process(501, "Not Implemented: " + msg.Arguments[0].ToUpper()); break; } server.Write(response.Data, 0, response.Length); server.WaitForPipeDrain(); server.Disconnect(); } } catch (Exception ex) { new LoggedError("BlockInput", ex, false, false).Write(); } }