2

I currently working on a application with a MapPoint-Control, which gives me a hard time. After starting a DoDragDrop from the thread, which mappoint also uses, i always get after a few secondes a dialog from mappoint saying my form doesn't react.

The MapPoint-Control is a ActiveX-Control, using the control MapPoint starts in the background and runs in a different thread. I think Mappoint trys to update the control but gets a timeout.

Is there a way to run DoDragDrop in a different thread, so MapPoint get response from the mainthread. Or is it possible to tell MapPoint my form is currently paused. Or can I somehow pause MapPoint?

I have tried to run the DoDragDrop with the form control and with the MapPoint-Control

Wowa
  • 1,791
  • 1
  • 14
  • 24

1 Answers1

2

I've found the problem.

I've fired DoDragDrop on the BeforeClick-Event. MapPoint probably wait for the Events callback, but don't get one because DoDragDrop keeps the Event up until the mouse is released.

Now i have written a Event which starts the DoDragDrop Event async to the MapPoint BeforeClick-Event.

Code:


public event InitDragDropHandler InitDragDrop;
public delegate void InitDragDropHandler(object sender, object data);

public main()
{
    this.InitDragDrop += new InitDragDropHandler(main_InitDragDrop);
}

void mappoint_BeforeClick(object sender, AxMapPoint._IMappointCtrlEvents_BeforeClickEvent e)
{
    if (InitDragDrop != null)
    {
        this.BeginInvoke(new ThreadStart(() =>
            {
                InitDragDrop(mappoint, pps);
            }));
    }
}


void main_InitDragDrop(object sender, object data)
{
    ((Control)sender).DoDragDrop(data, DragDropEffects.Copy);
}
Wowa
  • 1,791
  • 1
  • 14
  • 24
  • Does that mean the MapPoint Control is on its own thread? I'm a little surprised that works. I've used MapPoint application with other things on their own threads, but you have to be careful; and Windows does not like multiple threads using the same controls. – winwaed Jan 18 '11 at 14:22
  • After starting a DoDragDrop from the thread, which mappoint also uses,...I think he mean in the same thread – edze Jan 18 '11 at 14:38
  • @winwaed: Like edze said, the mappoint control runs in the mainthread, but thanks to begininvoke the InitDragDrop event is fired after the mappoints BeforeClick event is finished. – Wowa Jan 18 '11 at 14:44