Marin
05-03-2007, 06:42 AM
I have several istances of MapPoint.exe running at the same time, each one corresponding to one instance of a program i wrote. How can i identify which MapPoint.exe corresponds to a specific instance of a program?
I need it so that I could trac memory usage.
Wilfried
05-03-2007, 06:59 AM
Hi,
When you create the mappoint application the windows handle is returned. You could keep track of it. Remember windows handles are exclusive but not exclusive in time. If application shut down then the same handle can be something else a while later.
Marin
05-03-2007, 08:27 AM
When you create the mappoint application the windows handle is returned. You could keep track of it. Remember windows handles are exclusive but not exclusive in time. If application shut down then the same handle can be something else a while later.
Well i create the application with the following code
MapPoint.ApplicationClass app= new MapPoint.ApplicationClass();
How can I get the handle from that?
Wilfried
05-04-2007, 06:36 AM
Hi,
app is exclusive address to the object. So you can use the app variable.
Marin
05-04-2007, 06:38 AM
app is exclusive address to the object. So you can use the app variable.
Yes, but how can I determin memory usage of MapPoint.exe from the app object?
Wilfried
05-04-2007, 07:14 AM
Hi,
I'm not sure.
Process[] processes = Process.GetProcessesByName("MapPoint");
foreach (Process proc in processes)
if (proc.Handle == app)
But I'm not sure if the handle of the process is the same as the value of app. It can be the address of it. So if not I'm stuck as well.
Second thing is the memory application. proc has several properties for that. PagedMemorySize, NonPagedMemorySize etc...
Marin
05-04-2007, 07:26 AM
Hi,
I'm not sure.
Process[] processes = Process.GetProcessesByName("MapPoint");
foreach (Process proc in processes)
if (proc.Handle == app)But I'm not sure if the handle of the process is the same as the value of app. It can be the address of it. So if not I'm stuck as well.
proc.Handle and app are not comparable types so this can't work.
So, maybe, this workaround is the best that can be done.
Process thisProcess = Process.GetCurrentProcess();
app.Caption = thisProcess.Id.ToString();
Process[] procesi = Process.GetProcessesByName("MapPoint");
foreach (Process p in procesi)
{
if (p.MainWindowTitle == "Map - "+thisProcess.Id.ToString())
{
//p is the one
}
}
Can it be done easier?
Wilfried
05-04-2007, 11:04 AM
Hi,
proc.Handle and app are not comparable types so this can't work.
Both are unsigned 32 bit numbers. So you can typecast them to int or to IntPtr to compare. Worth to try and see if the number is the same :)
I dont know if there is other / simpler solution as the one you do. But seems ok if it works of course.