From: pjh9216 Date: Mon, 18 Feb 2019 00:14:07 +0000 (+0900) Subject: [Tizen.Applications.Common] Add a timer for handling GC collection (#716) X-Git-Tag: submit/tizen_5.0/20190218.050423~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1c914da8fc906ab8bccf2060a17b37a0334f35f;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Tizen.Applications.Common] Add a timer for handling GC collection (#716) * Add a timer for handling GC collection - Once apps receive low memory events, GC collection will happen at the same time. - This patch is for distribution of GC collection event. Signed-off-by: Junghoon Park * Use overloaded method for Random.next Signed-off-by: Junghoon Park --- diff --git a/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs b/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs old mode 100644 new mode 100755 index 298f635dc..6a72aee65 --- a/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.cs @@ -17,6 +17,7 @@ using System; using System.Globalization; using System.Text; +using System.Timers; using Tizen.Applications.CoreBackend; namespace Tizen.Applications @@ -30,6 +31,8 @@ namespace Tizen.Applications private readonly ICoreBackend _backend; private bool _disposedValue = false; + private static Timer sTimer; + /// /// Initializes the CoreApplication class. /// @@ -175,6 +178,14 @@ namespace Tizen.Applications protected virtual void OnLowMemory(LowMemoryEventArgs e) { LowMemory?.Invoke(this, e); + sTimer = new Timer(new Random().Next(10 * 1000)); + sTimer.Elapsed += OnTimedEvent; + sTimer.AutoReset = false; + sTimer.Enabled = true; + } + + private static void OnTimedEvent(Object source, ElapsedEventArgs e) + { System.GC.Collect(); }