[CE U16 C++]Best way to connect a desktop gui application sending and receiving large amounts of data

Hello,

we are currently migrating an application wich was using the COM connection (which isn't possible anymore due to the problem described here: https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/218237/ce-u16-c-unable-to-create-createcellelement1-with-the-com-api/666854#666854).
We planned to create a local tcp connection between our application and a microstation plugin where in the plugin the server runs in a thread and forwards the requests to microstation. This doesn't work because the Microstation api threw an access violation error when we called IACSManageR::GetManager(while researching this we found that the api apparently shouldn't be used from other threads https://communities.bentley.com/products/programming/microstation_programming/f/archived-microstation-v8i-programming-forum/60143/multi-threading-in-microstation-c-mdl-functions). 
So we are now looking for a way to get from the server thread back into the main thread. Our alternative solution would be to write the data to files and send the filenames via icp keyins. For responses from Microstation we would scan for new files at a known location when the engine->startApp call returns.

Do you know better alternatives to our current approach?

Kind regards,

Jonathan Unseld 

Parents
  • Hi Jan,

    I am not sure what problem with main thread and background process can be, because IPC supports both in-process and out of process communication.

    thanks for your reply, from our server thread we thought we would send TCP messages from our application to our plugin in microstation.

    The plugin  receives it in a thread, because otherwise it will freeze microstation. In the thread it would then call Api methods such as IACSManageR::GetManager. It is intended to transfer a layout from our application to microstation and vice versa. When calling for example IACSManageR::GetManager from the server thread we get an access violation exception.

    Kind regards,
    Jonathan

  • Hi Jonathan,

    from our server thread we thought we would send TCP messages from our application to our plugin in microstation

    I assume, when the communication is local, different IPC forms can be used. TCP messages is good choice, even when e.g. RPC can also be good alternative. Maybe the final choice should be done not on IPC type, but on what library, with what features, is available ;-)

    When calling for example IACSManageR::GetManager from the server thread we get an access violation exception.

    It's hard to say why it happens without knowing the code. But technically GetManager() is not called from the server thread, but it comes from server, converted to TCP message, received by MicroStation application code, and now GetManager() is called. Am I right?

    and shared good and important ideas.

    The main principle in MicroStation API is that it is single-threaded, so it can be called only from the main thread (UI thread, as mentioned by Francois). It is a responsibility of your code, if maintaining another thread to receive TCP messages from the server, to pass it to UI thread, so MicroStation API is not aware it comes from another source. It is common task of all multithreaded / multitask applications, so best practices and libraries are available. I guess it is probably easier today in NET, but many new features were added to the latest C++ versions, plus there is also Boost library.

    With regards,

      Jan

Reply
  • Hi Jonathan,

    from our server thread we thought we would send TCP messages from our application to our plugin in microstation

    I assume, when the communication is local, different IPC forms can be used. TCP messages is good choice, even when e.g. RPC can also be good alternative. Maybe the final choice should be done not on IPC type, but on what library, with what features, is available ;-)

    When calling for example IACSManageR::GetManager from the server thread we get an access violation exception.

    It's hard to say why it happens without knowing the code. But technically GetManager() is not called from the server thread, but it comes from server, converted to TCP message, received by MicroStation application code, and now GetManager() is called. Am I right?

    and shared good and important ideas.

    The main principle in MicroStation API is that it is single-threaded, so it can be called only from the main thread (UI thread, as mentioned by Francois). It is a responsibility of your code, if maintaining another thread to receive TCP messages from the server, to pass it to UI thread, so MicroStation API is not aware it comes from another source. It is common task of all multithreaded / multitask applications, so best practices and libraries are available. I guess it is probably easier today in NET, but many new features were added to the latest C++ versions, plus there is also Boost library.

    With regards,

      Jan

Children
No Data