Can any one please advise me how I can get the current count of “USER Object”s (as shown in task manager) for the current process.
I see how to get the handle count using:
Process.GetCurrentProcess.HandleCount
But our application can reach a USER Object count of 10,000 just by opening 17 instances of a particular form so we would like to try and warn a user that resources are getting low before they reach the limit and the application bombs.
If I’m thinking of the right kinds of user objects you can do it with the GetGuiResources API function. See the pinvoke page for it here for a C# sample (the second one that sends in 1 as the flag).
Here’s a VB translation of the code: