Question

I have been looking at the speed of my software trying to fine a line here and there that I can speed up. I do NOT need help with general optimisation. I have found a specific line of background unmanaged code that seems to be taking a very long time, even when the amount of calls are considered. This is the line:

system.windows.forms.unsafenativemethods.getwindowtext(handleRef hWnd, StringBuilder lpstring, int nMaxCount)

Does anyone know:

  1. how to speed it up/bypass it if it's not useful/replace it with something better.

  2. specifically where I would have written something in my code that causes this to be called - the more example the better on this one! I've found some related topics on Google. But each of these relate to a specific issue such as an error occurring when a one thread asks another thread for something and the other thread has become detached. This Link is helpful, but I can't quiet get my head around it. Any and all help will be appreciated.

Thanks!

Was it helpful?

Solution

It sounds like you're using Control.Text a lot - this seems like the most likely caller of GetWindowText.

If you're updating your UI with the results of your simulation every time the simulation makes progress, you may well be able to improve the performance significantly just by rate-limiting the updates (e.g. just update 5 times per second).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top