Table of Contents

Message Management

HiNc applications use three independent message categories. Each category serves a distinct purpose and should not be mixed.

Categories

1. Diagnostic — IProgress<object>

Operation-scoped progress and diagnostic messages. The caller provides an IProgress<object> to the callee, which reports progress, warnings, and errors through it.

  • Session-scoped: SessionProgress feeds the Session Message Panel.
  • XML IO chain: XFactory threads IProgress<object> through all deserialization calls so that parsing errors are reported to the caller rather than a global handler.
  • Script-level: SessionProgress exposes the session progress to user scripts.

Use MultiTagMessageUtil extension methods (ReportProgress, ReportMessage, ReportWarning, ReportError, ReportInfo) to report typed messages.

2. UI Error Notification — MessageBoardUtil

Toast-style popups for immediate user attention (e.g., “File saved”, “Load failed”). MessageBoardUtil triggers the ShowMessageBoard event consumed by the GUI layer.

Note

MessageBoardUtil is not yet mature for all scenarios. In practice, ILogger with level-filtered treatment is often applied instead.

3. App Log — ILogger

Standard .NET ILogger for application-level logging. Use ActionProgress<T>.FromLogger to bridge IProgress<object> APIs to an ILogger instance:

IProgress<object> progress = ActionProgress<object>.FromLogger(logger);

This routes MultiTagMessage to the appropriate log level (LogError, LogWarning, LogInformation) based on message tags.

Basic-Component / Utility Level

Low-level utilities (e.g., in Hi.Common, Hi.Geom) cannot assume which category the caller intends. These APIs accept Action<Exception> or IProgress<object> as parameters so the caller decides how to handle messages:

await task.CatchExceptions(ex => progress?.Report(ex));

Design Rationale

Static/global message sinks mix the three categories, making it unclear whether a message is diagnostic, UI notification, or app log. The current pattern threads the handler explicitly through the call chain so each caller decides the appropriate category.