/*
- * Copyright(c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public class Timer : BaseHandle
{
private bool played = false;
- private EventHandlerWithReturnType<object, TickEventArgs, bool> _timerTickEventHandler;
- private TickCallbackDelegate _timerTickCallbackDelegate;
+ private EventHandlerWithReturnType<object, TickEventArgs, bool> timerTickEventHandler;
+ private TickCallbackDelegate timerTickCallbackDelegate;
- private System.IntPtr _timerTickCallbackOfNative;
+ private System.IntPtr timerTickCallbackOfNative;
/// <summary>
/// Creates a tick timer that emits periodic signal.
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- internal Timer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Timer.Upcast(cPtr), cMemoryOwn)
+ internal Timer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
{
+ timerTickCallbackDelegate = OnTick;
+ timerTickCallbackOfNative = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(timerTickCallbackDelegate);
- _timerTickCallbackDelegate = OnTick;
- _timerTickCallbackOfNative = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(_timerTickCallbackDelegate);
-
- NUILog.Debug($"(0x{SwigCPtr.Handle:X})Timer() contructor!");
+ NUILog.Debug($"(0x{SwigCPtr.Handle:X})Timer() constructor!");
}
/// <summary>
/// </summary>
~Timer()
{
- Tizen.Log.Debug("NUI",$"(0x{SwigCPtr.Handle:X})Timer() distructor!, disposed={disposed}");
+ Tizen.Log.Debug("NUI", $"(0x{SwigCPtr.Handle:X})Timer() destructor!, disposed={disposed}");
}
- [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate bool TickCallbackDelegate();
/// <summary>
{
add
{
- if (_timerTickEventHandler == null && disposed == false)
+ if (timerTickEventHandler == null && disposed == false)
{
- TickSignal().Connect(_timerTickCallbackOfNative);
+ TickSignal().Connect(timerTickCallbackOfNative);
}
- _timerTickEventHandler += value;
+ timerTickEventHandler += value;
}
remove
{
- _timerTickEventHandler -= value;
- if (_timerTickEventHandler == null && TickSignal().Empty() == false)
+ timerTickEventHandler -= value;
+ if (timerTickEventHandler == null && TickSignal().Empty() == false)
{
- TickSignal().Disconnect(_timerTickCallbackOfNative);
+ TickSignal().Disconnect(timerTickCallbackOfNative);
}
}
}
{
Tizen.Log.Error("NUI", "current threadID : " + Thread.CurrentThread.ManagedThreadId);
-
StackTrace st = new StackTrace(true);
for (int i = 0; i < st.FrameCount; i++)
{
return ret;
}
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Timer obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
- }
-
/// <summary>
/// Sets a new interval on the timer and starts the timer.<br />
/// Cancels the previous timer.<br />
{
NUILog.Debug($"(0x{SwigCPtr.Handle:X}) Timer.Dispose(type={type}, disposed={disposed})");
- if (this != null && _timerTickCallbackDelegate != null)
+ if (this != null && timerTickCallbackDelegate != null)
{
- TickSignal().Disconnect(_timerTickCallbackOfNative);
+ TickSignal().Disconnect(timerTickCallbackOfNative);
}
if (disposed)
if (played == false)
{
Tizen.Log.Fatal("NUI", $"(0x{SwigCPtr.Handle:X}) OnTick() is called even played is false!");
- //throw new System.InvalidOperationException($"OnTick() excpetion!");
+ //throw new System.InvalidOperationException($"OnTick() exception!");
}
- if (_timerTickEventHandler != null && played == true)
+ if (timerTickEventHandler != null && played == true)
{
//here we send all data to user event handlers
- return _timerTickEventHandler(this, e);
+ return timerTickEventHandler(this, e);
}
return false;
}
{
}
}
-
}
-