Ejemplo n.º 1
0
            private void Main()
            {
                try
                {
                    while (true)
                    {
                        if (!TargetIsRunning)
                        {
                            if (state == State.AwaitingRespoonse)
                            {
                                thread?.Abort();
                                throw new Exception("Unrecoverable error state - target app was closed while awaiting a response.");
                            }
                            state = State.WaitForHandshake;
                            StartTargetExe();
                        }
                        switch (state)
                        {
                        case State.WaitForHandshake:
                            if (CheckForHandshake())
                            {
                                state = State.Ready;
                            }
                            else
                            {
                                Debug.LogError("Handshake w/ server failed");
                            }
                            break;

                        case State.Ready:
                            if (busy || IpcInteraction.awaitingResponseToSubmittedMessage)
                            {
                                continue;
                            }
                            IpcInteraction.ProcessQueue();
                            if (onReady != null)
                            {
                                var del = onReady.GetInvocationList()[0] as EventHandler;
                                onReady -= del;
                                del.Invoke(this, EventArgs.Empty);
                                busy = true;
                            }
                            else
                            {
                                Thread.Sleep(250);
                            }
                            break;

                        case State.AwaitingRespoonse:
                            string response;
                            if (CheckForResponse(out response))
                            {
                                ExportResponse(response);
                            }
                            else
                            {
                                Thread.Sleep(250);
                            }
                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    exceptions.AddLast(e);
                    Debug.LogError(e.StackTrace);
                    throw e;
                }
            }
Ejemplo n.º 2
0
 public IpcInteractionEventArgs(IpcInteraction _interaction) => interaction = _interaction;