/// <summary>
        /// Register a callback event function to be called when a device event (e.g. turn on, turn off) occurs
        /// </summary>
        /// <param name="eventFunc">Callback function to be called</param>
        /// <param name="obj">Context object that will be echoed back when function is called. Only the object when the first function is registered will be used. Set to null if not used.</param>
        /// <returns>Callback event id</returns>
        public unsafe int tdRegisterDeviceEvent(EventCallbackFunction deviceEventFunc, Object obj)
        {
            int returnValue = 0;

            if (deviceEventList.Count == 0)
            {
                //first added, register with dll too
                UnmanagedImport.EventFunctionDelegate deviceEventFunctionDelegate = new UnmanagedImport.EventFunctionDelegate(deviceEventFunction);

                registeredEventFunctionId = UnmanagedImport.tdRegisterDeviceEvent(deviceEventFunctionDelegate, (void *)null);                   //context here or above?
                GC.Collect();
                callbackFunctionReferenceList.Add(registeredEventFunctionId, deviceEventFunctionDelegate);
            }

            ++lastEventID;
            returnValue = lastEventID;
            DeviceEventFunctionContext deviceEventFuncContext = new DeviceEventFunctionContext();

            deviceEventFuncContext.eventCallbackFunc = deviceEventFunc;
            deviceEventFuncContext.context           = obj;
            deviceEventFuncContext.callbackId        = returnValue;
            deviceEventList.Add(returnValue, deviceEventFuncContext);

            return(returnValue);
        }
        /// <summary>
        /// Register a callback event function to be called when a device event (e.g. turn on, turn off) occurs
        /// </summary>
        /// <param name="eventFunc">Callback function to be called</param>
        /// <param name="obj">Context object that will be echoed back when function is called. Only the object when the first function is registered will be used. Set to null if not used.</param>
        /// <returns>Callback event id</returns>
        public unsafe int tdRegisterDeviceEvent(EventCallbackFunction deviceEventFunc, Object obj)
        {
            int returnValue = 0;

            if (deviceEventList.Count == 0)
            {
                //first added, register with dll too
                UnmanagedImport.EventFunctionDelegate deviceEventFunctionDelegate = new UnmanagedImport.EventFunctionDelegate(deviceEventFunction);

                registeredEventFunctionId = UnmanagedImport.tdRegisterDeviceEvent(deviceEventFunctionDelegate, (void*)null);	//context here or above?
                GC.Collect();
                callbackFunctionReferenceList.Add(registeredEventFunctionId, deviceEventFunctionDelegate);
            }

            ++lastEventID;
            returnValue = lastEventID;
            DeviceEventFunctionContext deviceEventFuncContext = new DeviceEventFunctionContext();
            deviceEventFuncContext.eventCallbackFunc = deviceEventFunc;
            deviceEventFuncContext.context = obj;
            deviceEventFuncContext.callbackId = returnValue;
            deviceEventList.Add(returnValue, deviceEventFuncContext);

            return returnValue;
        }