microsoft / microsoft/automatic-graph-layout

"LayoutProgress.LayingOut & Aborted" events are not handled on the UI thread, but other progress events are.

Open
#140 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.5k
Forks
319
Avg merge
38m
Merged PRs (30d)
1

Description

I am using the GViewer async rendering. I use below code to log info to a Label control.

It's strange that "LayoutProgress.LayingOut" is not handled on the UI thread.
But other prgress events are.

Maybe this is a bug?

The Progress event handler:

private void viewer_AsyncLayoutProgress(object sender, LayoutProgressEventArgs e)
{
    switch (e.Progress)
    {
        case LayoutProgress.Finished: // on the UI thread.
            Log(LogLevel.Info, "Graph rendered.");
            break;

        case LayoutProgress.Aborted: // NOT on the UI thread.
            Log(LogLevel.Error, "Graph rendering aborted.");
            break;

        case LayoutProgress.LayingOut: // NOT on the UI thread.
            Log(LogLevel.Info, "Graph laying out...");
            break;
        case LayoutProgress.Rendering: // on the UI thread.
            Log(LogLevel.Info, "Graph rendering...");
            break;
    }
}

The Log code:

public void Log(LogLevel logLevel, string msg)
{
    String header = "[INFO]: ";
    switch (logLevel)
    {
        case LogLevel.Error:
            header = "[ERROR]: ";
            break;
        case LogLevel.Info:
            header = "[INFO]: ";
            break;
        case LogLevel.Warning:
            header = "[Warning]: ";
            break;
    }

    String logMessage = header + msg + Environment.NewLine;
    if (!this.InvokeRequired) //<==== InvokeRequired == TRUE for "LayoutProgress.LayingOut & Aborted" events.
    {
        this.txt_output.AppendText(logMessage);
    }
    else
    {
        this.Invoke(new MethodInvoker(() => { this.txt_output.AppendText(logMessage); }));
    }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the GViewer async rendering entry point and the AsyncLayoutProgress event handler, reproducing the reported thread behavior with the provided WinForms logging code. Trace how LayingOut, Aborted, Rendering, and Finished are dispatched; done means progress events have consistent UI-thread behavior or the documented behavior is clarified.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.