/// <summary> /// Process the memory message described by msg. /// </summary> /// <param name="msg"> The message. This cannot be null</param> /// <returns> True if it succeeds, false if it fails</returns> bool ProcessMemoryMessage([NotNull] MemoryUpdateMessage msg) { WriteLineInColor("Received Memory Update Message", ConsoleColor.Yellow); RILogManager.Default?.SendInformation("Received Memory Update Message"); msg.ID = new Random().Next(7000001, 8000000); using (var _db = new LiteDatabase(connectionString)) { Thread.Sleep(5); _db.Shrink(); var collection = _db.GetCollection <MemoryUpdateMessage>(); collection.EnsureIndex(x => x.ID); collection.Insert(msg); } return(true); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Publish memory update message. </summary> /// /// <param name="gen1"> The first generate. </param> /// <param name="gen2"> The second generate. </param> /// <param name="timeSpent"> The time spent. </param> /// <param name="MemoryBefore"> The memory before. </param> /// <param name="MemoryAfter"> The memory after. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// public void PublishMemoryUpdateMessage(int gen1, int gen2, float timeSpent, string MemoryBefore, string MemoryAfter) { // publish a message MemoryUpdateMessage msg = new MemoryUpdateMessage { Text = "Memory MicroService Ran", Date = SystemClock.Instance.GetCurrentInstant().ToDateTimeUtc(), Gen1CollectionCount = gen1, Gen2CollectionCount = gen2, TimeSpentPercent = timeSpent, MemoryBeforeCollection = MemoryBefore, MemoryAfterCollection = MemoryAfter }; Bus.Publish(msg, "MemoryStatus"); }