Can I speed up callbacks from C ++ Dll to C #?

We implemented our core code functions in C ++ Dll, and then wrote C # UI on top. This works great in most cases, but in areas where we want the user interface to report the progress of a function in C ++, we have some performance issues.

We pass a pointer to a C # function up to the Dll for use to update progress. When called, we use InvokeRequired and Invoke () to make sure the callback is thread safe. Measured from the side of C ++, this can take from 16 ms to 180 ms. Is there a way to reduce the time it takes?

One of these callbacks passes the location of the line that should be drawn on the screen. This drawing is currently very slow - I assume that the called functions are in the queue and require the time that needs to be drawn in C #. I see two ways to deal with this: 1. Change the callback to send a list of strings and allow queues in the queue in C ++, waiting for the previous C # call to complete. 2. Adding lines to the queue in C # (preferably without invoking Invoke), and then drawing all the lines that are available immediately. Any suggestions on how to do this, are both options or alternative methods needed?

Thanks for any help.

+3
source share
3 answers

BeginInvoke Invoke. Invoke , BeginInvoke .

+3

, . Invoke - . , . . , , .

:

  • BeginInvoke - , .
  • , , . OUTSIDE ++ dll - corodinates , BeginInvoke.

, , #.

, . ++ # , #. API, , (Invoke) , , , . ## Smalltalk, Assembler, #, Visual Basic, 100% .

+1

, , . # ? . , , . , .

@Edit: ++- #. , .NET , . .NET( , ). , ++ .

0
source

Source: https://habr.com/ru/post/1795944/


All Articles