Async AutoLayout

I have a diagrams that can sometimes have 1300 nodes. When I use the auto layout it takes a good 30 min.
Is there a way to run it async so that I can let the user do something else. Or just to let the user a abort/calcel button so that they quite in the middle?

Version 2.5 has easier-to-use support for running the layout in a separate thread. See the last section of the 2.5 GoLayout User Guide.
Also, version 2.5 layout (all kinds) should be faster than earlier versions. GoLayoutLayeredDigraph has a new PackOptions property to control the quality of the results and a significant chunk of time.
Finally, version 2.5 includes a GoLayoutTree, which for graphs that are more-or-less tree-structured, is a lot faster and a lot more featureful than using GoLayoutLayeredDigraph.

trying to run the code from the the 2.5 GoLayout User Guide.
gives the following error, when it tries to access goView1:
An unhandled exception of type ‘System.InvalidOperationException’ occurred in System.Windows.Forms.dll
Additional information: Cross-thread operation not valid: Control ‘tbProcessing’ accessed from a thread other than the thread it was created on.

Can you tell what the operation was?

It was something else on the application side.
Thanks a lot.

I assume you replaced SetStatusMessage in here to something like tbProcessing.Text = <span style=“font-size: 10pt; font-family: “Courier New”;” lang=“EN-US”>((int)(e.Progress*100)).ToString() + “% done”;

void layout_Progress(object sender, GoLayoutProgressEventArgs e) {

// substitute your own informational mechanisms...

SetStatusMessage(((int)(e.Progress*100)).ToString() + "% done");


You need to create a delegate to handle updates to the GUI from a different thread. Have a look at this article for more background



Actually, that’s not necessary for GoLayout.Progress events. If you set GoLayout.View, GoLayout.RaiseProgress will check InvokeRequired, and if so, call Invoke.