An asynchronous drawing is in progress. Check the IsBusy property before calling this.

Oct 10, 2008 at 5:03 PM
when I try to update the the graph twice in a row I get  this exception:
Microsoft.NetMap.Visualization.NetMapControl.BeginUpdate: An asynchronous drawing is in progress.  Check the IsBusy property before calling this.
I can not find the IsBusy property in the Graph or NetMapControl...
How can I safely update the graph twice in a row?

Thanks in advance

Matteo Prosperi
Oct 10, 2008 at 5:39 PM
Edited Oct 10, 2008 at 5:40 PM

I'll fix the error message, which came from a previous version of the control.  The correct property name is "IsDrawing".  You can't update the control while this property is true.  You can also monitor the DrawingGraph and GraphDrawn events to determine when updates are allowed.

Why this restriction?  It's because graph layouts are performed on a secondary thread, and I wanted to minimize the multithreading nightmares that could occur if the secondary thread and the primary UI thread tried to simultaneously modify the graph.  In the Excel template, I disable the graph pane's UI while the graph is drawing, thus preventing such conflicts.

We have several work items for the control that might modify this restriction in the future (including a rewrite in WPF), but for now you have to wait for the graph to finish drawing before you can update the graph.

-- Tony
Oct 10, 2008 at 5:57 PM

I'm wondering why you're updating the graph twice in a row.  Are you trying to animate the graph?  If so, you can do that by waiting until the initial drawing is complete, then modifying the IVertex.Location properties and calling NetMapControl.ForceRedraw(), which doesn't involve a secondary layout thread.  The following sample code randomly animates the graph's vertices in response to a button click:

private void btnAnimate_Click(object sender, EventArgs e)
    Random oRandom = new Random();

    foreach (IVertex oVertex in netMapControl1.Graph.Vertices)
        oVertex.Location = new PointF(


Oct 13, 2008 at 9:23 AM

thank you very much for the clarification.

I'm using NetMap to display a state machine layout. The state machine can be modified (states and transitions added and removed) asyncronously by code in one or more different threads. When I receive the notification of a layout change I need to edit the NetMap graph to display the current status.
I will also need to change colors and label upon notification.
I understand that I can do the label and color editing using the ForceRedraw() method but I will need to perform a full layout checking the IsDrawing property when nodes and arcs are added or removed.

I have also another question: is it possible to force maximum and minimum length for arcs? I would like to have a graph coposed of "parent nodes" and every "parent node" have a group "child nodes" which are kept near the parent.

Thank youy

Matteo Prosperi
Oct 13, 2008 at 4:56 PM


There is currently no way to force maximum and minimum length for arcs.  The Fruchterman-Reingold algorithm tries to keep children near the parent, but its effectiveness varies with the data set.

Here is part of my response to another question that might be helpful to you:

If you're using the FruchtermanReingoldLayout and you're not happy with the results, try calling NetMapControl.ForceLayout() one or more times after the initial drawing completes.  (You can monitor the GraphDrawn event for this.)  The Fruchterman-Reingold algorithm is iterative -- it lays out the vertices repeatedly, using the previous vertex locations as a starting point.  The initial drawing uses 10 iterations, which may or may not be enough to place the vertices in sensible locations.  Each call to ForceLayout() forces another 10 iterations, which can sometimes improve things considerably.  It all depends on the data set.

-- Tony