Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

C#: How to find out if MapPoint is still running?

This is a discussion on C#: How to find out if MapPoint is still running? within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello, I create a MapPointApplication with the following code: Code: ApplicationClass mapPointApplication = new ApplicationClass(); Then I add pushpins to ...

  1. #1
    MD2000 is offline Member Yellow Belt
    Join Date
    Feb 2005
    Posts
    32

    C#: How to find out if MapPoint is still running?

    Hello,
    I create a MapPointApplication with the following code:

    Code:
    ApplicationClass mapPointApplication = new ApplicationClass();
    Then I add pushpins to it:

    Code:
    mapPointApplication.ActiveMap.AddPushpin(location, "1");

    How can I check if MapPoint is still running and hasn't been closed by the user?

    Bye,

    MD

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Something like this:

    Code:
    using System.Diagnostics;
    
            private bool IsMPRunning()
            {
                Process[] processes = Process.GetProcessesByName("MapPoint");
                return (processes.Length > 0);
            }
    I did not test this, just from the top of my head

  3. #3
    MD2000 is offline Member Yellow Belt
    Join Date
    Feb 2005
    Posts
    32
    I thought about this one, too. But the problem could be: The user could have closed MapPoint and restarted it. So with your method, I wouldn't be sure if it is the same MapPoint instance that I created before.

    Bye,

    MD

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    I cannot find ApplicationClass in my help But I'm pretty sure you can retreive his windows handle. Later when you wants to check if this particular instance of Mappoint is still running you can probably do it this way:

    Code:
            private bool IsThisOneRunning(IntPtr h)
            {
                Process[] processes = Process.GetProcessesByName("MapPoint");
                foreach (Process proc in processes)
                    if (proc.Handle == h)
                        return true;
                return false;
            }

  5. #5
    MD2000 is offline Member Yellow Belt
    Join Date
    Feb 2005
    Posts
    32
    I thought about something like this:

    Code:
    mapPointApplication.BeforeClose += new MapPoint._ApplicationEvents_BeforeCloseEventHandler(mapPoint_Closing);
    But the code is not totally right.
    I'm not so familiar with eventhandler. Do you know how add the right event handler for the beforeclose Event?

    Bye,

    MD

  6. #6
    MD2000 is offline Member Yellow Belt
    Join Date
    Feb 2005
    Posts
    32
    Here's the Visual Basic code from the MapPoint help:
    Code:
      Dim WithEvents objApp As MapPoint.Application
    
      Private Sub Command1_Click()
        'Refresh the map using NewMap
        objApp.NewMap
      End Sub
    
      Private Sub Form_Load()
        'Set up the application
        Set objApp = CreateObject("mappoint.application")
        objApp.Visible = True
        objApp.UserControl = True
      End Sub
    
      Private Sub objApp_BeforeClose(Cancel As Boolean)
        MsgBox "BeforeClose event fired"
      End Sub
    How do I add this event handler in C#?

    Bye,

    MD

  7. #7
    MD2000 is offline Member Yellow Belt
    Join Date
    Feb 2005
    Posts
    32
    I cannot get it work

    The constructor should be:
    new MapPoint._ApplicationEvents_BeforeCloseEventHandle r(void (out bool) target)


    How should the signature of the mapPoint_Closing methode look like?

    Bye,

    MD

  8. #8
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    I'm not sure:

    Code:
    public void Map_BeforeClose(ref bool Cancel);
    new MapPoint._ApplicationEvents_BeforeCloseEventHandler(Map_BeforeClose)

  9. #9
    MD2000 is offline Member Yellow Belt
    Join Date
    Feb 2005
    Posts
    32
    It says:

    Method 'server.ServerGUI.mapPoint_Closing(ref bool)' doesnt comply with the Delegat 'void MapPoint._ApplicationEvents_BeforeCloseEventHandle r(out bool)'.

    Any idea? I'm totally lost with the delegat and out thing.

    Bye,

    MD

  10. #10
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help!! Error running mappoint
    By gag in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-27-2004, 11:45 PM
  2. I currently have Mappoint 2000 running on my PC. (....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-11-2002, 01:44 PM
  3. I am currently running Mappoint 2001 and will buy ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-19-2001, 09:49 AM
  4. I am currently running the MapPoint 2002 Trial. I....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-04-2001, 09:45 AM
  5. I am currently running the MapPoint Trial. (I alre....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-27-2001, 09:13 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27