[NUI] Dispose queue incrementally
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Common / ProcessorController.cs
index 3a968a2..0132e90 100755 (executable)
@@ -34,6 +34,7 @@ namespace Tizen.NUI
     internal sealed class ProcessorController : Disposable
     {
         private static ProcessorController instance = null;
+        private bool initialied = false;
 
         private ProcessorController() : this(Interop.ProcessorController.New(), true)
         {
@@ -41,16 +42,9 @@ namespace Tizen.NUI
 
         internal ProcessorController(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
         {
-            onceEventIndex = 0u;
-            internalProcessorOnceEvent = new EventHandler[2];
-            internalProcessorOnceEvent[0] = null;
-            internalProcessorOnceEvent[1] = null;
-
-            processorCallback = new ProcessorEventHandler(Process);
-            Interop.ProcessorController.SetCallback(SwigCPtr, processorCallback);
         }
 
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate void ProcessorEventHandler();
 
         private ProcessorEventHandler processorCallback = null;
@@ -73,6 +67,8 @@ namespace Tizen.NUI
         public event EventHandler ProcessorEvent;
         public event EventHandler LayoutProcessorEvent;
 
+        public bool Initialized => initialied;
+
         public static ProcessorController Instance
         {
             get
@@ -85,6 +81,25 @@ namespace Tizen.NUI
             }
         }
 
+        public void Initialize()
+        {
+            if (initialied == false)
+            {
+                initialied = true;
+
+                Interop.ProcessorController.Initialize(SwigCPtr);
+
+                onceEventIndex = 0u;
+                internalProcessorOnceEvent = new EventHandler[2];
+                internalProcessorOnceEvent[0] = null;
+                internalProcessorOnceEvent[1] = null;
+
+                processorCallback = new ProcessorEventHandler(Process);
+                Interop.ProcessorController.SetCallback(SwigCPtr, processorCallback);
+                NDalicPINVOKE.ThrowExceptionIfExists();
+            }
+        }
+
         public void Process()
         {
             // Let us add once event into 1 index during 0 event invoke
@@ -130,6 +145,7 @@ namespace Tizen.NUI
         public void Awake()
         {
             Interop.ProcessorController.Awake(SwigCPtr);
+            NDalicPINVOKE.ThrowExceptionIfExists();
         }
     } // class ProcessorController
 } // namespace Tizen.NUI