コード例 #1
0
        public EventPipeListener(int targetProcessId, IEnumerable <EventPipeProvider> providers)
        {
            var client = new DiagnosticsClient(targetProcessId);

            _listeningSession = client.StartEventPipeSession(providers);

            _eventSource = new EventPipeEventSource(_listeningSession.EventStream);

            _eventSource.Kernel.All  += (TraceEvent @event) => KernelEvents?.Invoke(@event);
            _eventSource.Clr.All     += (TraceEvent @event) => ClrEvents?.Invoke(@event);
            _eventSource.Dynamic.All += (TraceEvent @event) => CustomEvents?.Invoke(@event);
            Task.Factory.StartNew(() => _eventSource.Process(), _cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);

            //with a code like this we can output a memory dump depending on some threshold of CPU usage

            /*
             * _eventSource.Dynamic.All += (TraceEvent obj) =>
             *      {
             *          if (obj.EventName.Equals("EventCounters"))
             *          {
             *              IDictionary<string, object> payloadVal = (IDictionary<string, object>)(obj.PayloadValue(0));
             *              IDictionary<string, object> payloadFields = (IDictionary<string, object>)(payloadVal["Payload"]);
             *              if (payloadFields["Name"].ToString().Equals("cpu-usage"))
             *              {
             *                  double cpuUsage = Double.Parse(payloadFields["Mean"]);
             *                  if (cpuUsage > (double)threshold)
             *                  {
             *                      client.WriteDump(DumpType.Normal, "./minidump.dmp");
             *                  }
             *              }
             *          }
             *      }
             */
        }
コード例 #2
0
    public void UserLoses()
    {
        if (ListeningToOrders)
        {
            LoseDisplayScore.GetComponent <Text>().text = "Score :" + Score.ToString();
            UserLosesEvents.Invoke();
            ListeningToOrders = false;
//			Invoke ("ReloadScene", 3f);
        }
    }
コード例 #3
0
 public void UserWins()
 {
     if (ListeningToOrders)
     {
         Score += 10;
         WinDisplayScore.GetComponent <Text>().text = "Score :" + Score.ToString();
         UserWinsEvents.Invoke();
         ListeningToOrders = false;
         Invoke("ReloadScene", 3f);
     }
 }