[CONNECT .NET] How to listen to the EnterIdleEvent with the CONNECT .NET API or P/Invoke?

I can't find any way of listening to the EnterIdleEvent with the CONNECT .NET API. I guess it was possible in V8i to P/Invoke  "mdlInput_setFunction (INPUT_ENTER_IDLE, OnEnterIdleState);" to get the same event, but it seems that this function is not exported in CONNECT anymore.

Is there any replacement?

Parents
  • Well, at the end, it was not too complicated to receive some more information using standard approach and tools (MicroStation SDK Update 12 used):

    1. Macro sdksearch available in MicroStation SDK shell provides first insight: skdsearch mdlInput_setFunction found that mdlInput_setFunction(INPUT_ENTER_IDLE,*) is available in remap definition and it points to InputCallback::SetEnterIdleFunction.
    2. Whereas InputCallback::SetEnterIdleFunction is documented in MicroStation API, the method SetEnterIdleFunction not. I recommend to raise service ticket for this issue, also is probably able to get some insight why the remap tool knows it, but documentation not.
    3. Even when it's not documented, using DLL Export Viewer confirms it's published in ustation.dll.

    With regards,

      Jan

    Answer Verified By: Tomáš Juřík 

Reply
  • Well, at the end, it was not too complicated to receive some more information using standard approach and tools (MicroStation SDK Update 12 used):

    1. Macro sdksearch available in MicroStation SDK shell provides first insight: skdsearch mdlInput_setFunction found that mdlInput_setFunction(INPUT_ENTER_IDLE,*) is available in remap definition and it points to InputCallback::SetEnterIdleFunction.
    2. Whereas InputCallback::SetEnterIdleFunction is documented in MicroStation API, the method SetEnterIdleFunction not. I recommend to raise service ticket for this issue, also is probably able to get some insight why the remap tool knows it, but documentation not.
    3. Even when it's not documented, using DLL Export Viewer confirms it's published in ustation.dll.

    With regards,

      Jan

    Answer Verified By: Tomáš Juřík 

Children
  • Hi Jan,

    thank you for your helpful replies. The InputCallback::SetEnterIdleFunction method is public so it is callable. I have tried it with P/Invoke and it works well. See the code snippet bellow.

    However, the exported name is decorated so the P/Invoke way of calling the method is not the best approach. Using the older C# COM API or C++/CLI wrapper is preferable.

    Tom

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    private delegate void InputFunc_EnterIdle();
    
    [DllImport("ustation.dll",
      EntryPoint = "?SetEnterIdleFunction@InputCallback@@SAP6AXH@ZP6AXH@Z@Z",
      ExactSpelling = true,
      CallingConvention = CallingConvention.Cdecl)]
    private static extern InputFunc_EnterIdle InputCallback_SetEnterIdleFunction(InputFunc_EnterIdle newFunc);

  • However, the exported name is decorated so the P/Invoke way of calling the method is not the best approach

    I agree. The solution would be report this issue to Bentley and to ask to add this event to API (because it's mentioned in migration tool already).

    Using the older C# COM API or C++/CLI wrapper is preferable.

    Personally I prefer to use C++/CLI and to create own wrapper in all situations when it's not just one simple call of native API. In contrast to Interop it allows to stay close to native API and implement as much as possible there and also to optimize memory allocation and performance (which should be always priority when working with system events). On the other hand, Interop API allows to keep code simple and does not require to create ectra C++/CLI assembly ;-)

    I hope we will see soon whether this issue is solved in Update 13.

    Regards,

      Jan