Process Management , Using MapPoint AX with .NET

September 26th, 2008

Last week, I came across a weird problem of MapPoint activeX using .NET. Here is a list of steps to generate this bug:
• Create a sample .NET application and use Mappoint activeX control in it.
• Run your application
• Run Task manager (Ctrl+Alt+Del) and kill the process of your application (not active process i.e. MapPoint.exe)
• Now you will see MapPoint.exe process is still running even its parent application is no more in the memory
• Now run your application again
• Your application will go in a long long wait state.
Weird!!!!!!!!!! Isn’t it?
Ok no worries, I got a solution for it. Though it is not a perfect solution (if you have any other, share with me) but it works for me.
Solution:
Create a text/XML file. On every form you load Mappoint active i.e. load maps, make an entry in the file with your application ID (you can get it by System.Diagnostics.Process.GetCurrentProcess().Id) and recent start time tick of your activeX control.

e.g

Process[] proc = Process.GetProcessesByName(”MapPoint”);
Log.Add(AppID,AX.proc[0].starttime.tick);
and on every form close delete this entry from log (this shows form was properly closed, not killed forcibly). Now if user kills your application process forcibly, all the running MapPoint processes’ handles are in log 
On application load, query your log and kill all mappoint processes as well delete entries from log file. Please note that before killing mappoint process you have to check corresponding application id.
i.e. get process by application id (you have saved appid with mappoint handle in log) , if you don’t find it alive that means there is no associated application with that mappoint, so simply kill that process, otherwise if application main window is not hidden and kill the mappoint process.
Here is example:
Process proc = null;
Try {proc = Process.getProcessByID(APPID); }
catch(ArgumentException ex) /*if application process is no more alive*/
{
KillProcess(MapPointHandle);
}
If(proc !=null)
{
IntPtr Handle = proc.MainWindowHandle;
If(Handle.equals(IntPtr.Zero)) /*if main window of application is no more visible*/
KillProcess(MapPointHandle);
}

It works perfect for me. Let me know if you need any help

Please comment on this if you have better solution

IT Outsourcing for Small Business

September 23rd, 2008

If you have a company with a major task in hand ie to integrate two system in different or to have development an interface or agent between the two applications - and you are not a programmer. Then there are chances that you are going to outsource the project.

The Finance director of Mission: Renaissance said (for the whole article click here)

“I didn’t do it myself because I didn’t know how – I am not a programmer,” said Oscar Camarena, finance director of Mission: Renaissance, Inc., a fine art instruction organization with over 100 staff. “The primary factor in deciding to outsource – we couldn’t do it in house.”