Skip to main content

LazyMessage

Namespace: Wisej.Web.Ext.ChatControl

Assembly: Wisej.Web.Ext.ChatControl (4.1.0.0)

A Message with a deferred result.

public class LazyMessage : Message

A LazyMessage is added to the ChatBox with empty content and displays an animated loading indicator until SetResult is called with the final content. Use it for responses that take time to produce, such as replies from a remote service or an AI model.

Example:

var bot = new User("bot", "Assistant");
var reply = new LazyMessage(bot);
chatBox.DataSource.Add(reply);

// later, when the response is available.
reply.SetResult("Here is your answer.");

Constructors​

Instance member LazyMessage(user)​

Creates a new instance of LazyMessage with the given user.

NameTypeDescription
userUserThe user associated with the message. When null, the ChatBox assigns its own User when the message is added.

Example:

var pending = new LazyMessage(new User("bot", "Assistant"));
chatBox.DataSource.Add(pending);

Instance member LazyMessage(user, contentType)​

Creates a new instance of LazyMessage with the given user and content type.

NameTypeDescription
userUserThe user associated with the message. When null, the ChatBox assigns its own User when the message is added.
contentTypeStringThe content type of the message, stored in ContentType; can be null.

The message starts with an empty Content. When its control is assigned, the control shows a loading image (Images/loading.svg) with a minimum size of 60x16 pixels.

Example:

var pending = new LazyMessage(new User("bot", "Assistant"), "text/markdown");
chatBox.DataSource.Add(pending);

Methods​

Instance member SetResult(content)​

Sets the content of the message and removes the loading indicator.

ParameterTypeDescription
contentStringThe message content.

Updates Content and the text of Control, clears the loading image and resets the control's minimum size. Call it only after the message has been added to a ChatBox, since Control is null until then.

Example:

var reply = new LazyMessage(new User("bot", "Assistant"));
chatBox.DataSource.Add(reply);
reply.SetResult("The weather today is sunny.");