LazyMessage
Namespace: Wisej.Web.Ext.ChatControl
Assembly: Wisej.Web.Ext.ChatControl (4.1.0.0)
A Message with a deferred result.
- C#
- VB.NET
public class LazyMessage : Message
Public Class LazyMessage
Inherits 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
LazyMessage(user)
Creates a new instance of LazyMessage with the given user.
| Name | Type | Description |
|---|---|---|
| user | User | The 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);
LazyMessage(user, contentType)
Creates a new instance of LazyMessage with the given user and content type.
| Name | Type | Description |
|---|---|---|
| user | User | The user associated with the message. When null, the ChatBox assigns its own User when the message is added. |
| contentType | String | The 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
SetResult(content)
Sets the content of the message and removes the loading indicator.
| Parameter | Type | Description |
|---|---|---|
| content | String | The 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.");