Notes on using with Visual C#

Function specifications

The class library is being offered as an interface for C#. The driver functions are called from the methods of the class library. The methods in the class library are defined in the form of removing the prefix of original functions. Please call the method with the name that does not contain the prefix of original function.

For example, when you want to call the TimInit function
Ret = tim.Init();

 

Function parameters and return value

The contents of the parameters and the return value of a function are independent of the development language, and are common. Please refer to the function reference for details.

 

Notes of using callback function

When notifying an interval timer event by using callback function in Visual C#, it is required to fix the callback function's memory address.

The following code is the sample to process an interval timer event.
For details, please refer to the sample programs.

- Declaring as global variables.

GCHandle gCh;
PTM_INTERVAL_CALLBACK pdelegate_func;
IntPtr pfunc;

- In the Load method, initializing the delegate for interrupt process, and add a reference to prevent garbage collection from being destroyed.

pdelegate_func = new PTM_INTERVAL_CALLBACK(CallBackProc);
gCh = GCHandle.Alloc(pdelegate_func);

- In the Close method, releasing the handle.

gCh.Free();

- Retrieving the fixed function pointer.

pfunc = Marshal.GetFunctionPointerForDelegate(pdelegate_func);

- Specifying the retrieved fixed pointer by function TimTimerCallBackProc.

Ret = timerw.TimerCallBackProc(Id, pfunc, Temp);