I would like to add a progress indicator to our ArcGIS Engine application. Like a progressbar in the statusbar to show when the MapControl is busy getting or drawing the map. I've been trying to find any resources in the documentation on how to do this, but all resources I find is pointing to the MxStatusBar that is only in the ArcGIS Desktop. Does anyone know which events I should be using to create my own progress indicator?

Update: It's a standalone ArcGIS Engine Application. Built in VB.Net using WinForms. We've created the graphical animation for our busy indicator. So that we can start and stop the animation when there is progress. This was created using a dialog running in it's own thread because the MapControl block the redrawing of the form during it's draw phase. We've tried to hook up the busy indicator to AxMapControl1_OnBeforeScreenDraw and AxMapControl1_OnAfterScreenDraw events. But these events are thrown even when the map is repainted,for.ex. when a dialog is dragged over the map.

We've also tried manually using the IMapControlEvents2 and it gives the same result.

We have tried to add the IDisplayEvent but it only get triggered on start up not when we pan and zoom the map. Here is some code I used to test the events with:

Have also tried using the ILayerStatus by implementing the IStepProgressor callback on the MapServerLayer, but it was also a disapointment, it get triggered after the image has been fetched from the server.

Does anyone know if there is an event that we can use that only get triggered when the Map is getting data form its datasource?

+1 I think this problem can be more generally stated: "Any workaround for ArcEngine UI thread blocking?" Put a mapcontrol and a textbox (multiline= true) on a form. Load some layers that take a really long time to draw. Run the app. While the map is drawing, try to edit text in the text box. Haven't tried it with 10.0, but was big problem in 9.3. Workaround was to put the mapcontrol in a separate process and position its window on top of a form that has the textbox. For simple animation there's probably a way (after all, arcmap can do it). I'd like to see a more general solution though.
–
Kirk KuykendallAug 19 '10 at 16:05

2

That's the way we've solved it, but we did it the other way around, we created the progress indicator in a different thread and put it on top of a panel in the form, making the impression that it's in the form. I agree it would be nice with a more general solution. The problem for me right now is that I can't find an event that tells me when the map is busy. Our architecture is based on having a server layer as a background layer and that layer is slow. Making it important o show the user that it's working. Do you know if it somehow is possible to find out when a layer is getting data?
–
MathiasWestinAug 19 '10 at 17:49

3 Answers
3

The code below works for me. If you load a new map, you'll need to re-wire your events. Maybe try start animating when IDisplayEvents.Start fires (and IViewRefresh.Drawing is true). Then stop animating when IActiveViewEvents.AfterDraw fires with drawPhase == esriViewDrawPhase.esriViewForeground.

It worked better when we wired the events after loading the Map. But it's a bit hard to get a single start event, when zooming anv panning the DisplayStarted with IViewRefresh.Drawing=true is thrown five times before I get a Finish event.
–
MathiasWestinAug 23 '10 at 14:23

Thanks for sharing the code it helped me to solve the problem.
–
MathiasWestinAug 26 '10 at 14:31

If your ArcEngine code runs inside a ArcGIS Desktop application, then the MxStatusBar (or the IStatusBar interface) seems appropriate. In that case, refer to IStatusBar.ProgressBar. (ArcEngine also offers progress dialogs — IProgressDialog2 — but that's a full dialog window and apparently not what you're after.)

If your code runs outside of any ArcGIS application, ie. it has its own GUI, you will most likely have to check out the corresponding functionality with your platform's GUI framework (Windows Forms or WPF for .NET; MFC, wxWidgets for C++, Swing / AWT / whatever for Java, etc.).

It's a standalone ArcGIS Engine Application. Built in VB.Net using WinForms. We've created the graphical animation for our busy indicator. So that we can start and stop the animation when there is progress. This was created using a dialog running in it's own thread because the MapControl block the redrawing of the form during it's draw phase. We've tried to hook up the busy indicator to AxMapControl1_OnBeforeScreenDraw and AxMapControl1_OnAfterScreenDraw events. But these events are thrown even when the map is repainted,for.ex. when a dialog is dragged over the map. Do you know a better event?
–
MathiasWestinAug 18 '10 at 11:11