Exemple #1
0
        private static List <T> Dequeue <T>(int count)
        {
            var ret = new List <T>();

            while (ret.Count < count)
            {
                if (!TryEnterQMonitor(3))
                {
                    continue;                       //Could not obtain lock after 3 tries waiting 5 seconds each
                }
                try
                {
                    ret.Add((T)Q.Dequeue());
                }
                catch (InvalidOperationException)
                {
                    OnReport?.Invoke($"[###Thread: {Thread.CurrentThread.ManagedThreadId}###] queue is empty");
                    count = 0;//don't try to get any more from empty queue
                }
                finally
                {
                    Monitor.Pulse(Q);
                    Monitor.Exit(Q);
                }
            }

            return(ret);
        }
        private static void ExportReport(string report)
        {
            Report r = Report.CreateTextReport("Logs", report);



            OnReport?.Invoke(null, new ReportManagerEventArgs(r));
        }
Exemple #3
0
 private void TriggerLogChanged(Report text)
 {
     try
     {
         OnReport?.Invoke(text);
     }
     catch (Exception e)
     {
         LogManager.Error($"Exception during Report Handling: {e.Message}");
         LogManager.Error(e.StackTrace);
     }
 }
        private bool Report()
        {
            EmitLog("Processing report command");
            if (!IsPlaced)
            {
                return(false);
            }

            var status = $"{X},{Y},{FacingAsString}";

            OnReport?.Invoke(status);
            return(true);
        }
Exemple #5
0
        private static void CreateQueueListener(Action <object> msgAction, CancellationToken ctx)
        {
            lock (Q)
            {
                while (!ctx.IsCancellationRequested)
                {
                    if (Q.Count == 0)
                    {
                        Monitor.Wait(Q);
                    }

                    try
                    { msgAction(Q.Dequeue()); }
                    catch (InvalidOperationException)
                    { OnReport?.Invoke($"[###Thread: {Thread.CurrentThread.ManagedThreadId}###] queue is empty"); }
                }
            }
        }
Exemple #6
0
 private void OnReportUserButtonPressed()
 {
     OnReport?.Invoke(userId);
     Hide();
 }
Exemple #7
0
 private void OnReportUserButtonPressed()
 {
     OnReport?.Invoke(userId);
     WebInterface.SendReportPlayer(userId);
     Hide();
 }
Exemple #8
0
 public void Report(Text report)
 {
     Console.WriteLine(report.Content);
     OnReport?.Invoke(report);
 }
Exemple #9
0
 public void Report(AbstractSimulationInfo info)
 {
     OnReport?.Invoke(info);
 }
 void IProgress <T> .Report(T value) => OnReport?.Invoke(value);
 private void OnReportUserButtonPressed()
 {
     OnReport?.Invoke(targetEntry);
     Hide();
 }