-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
area-controls-listviewListView and TableViewListView and TableViewp/2Work that is important, but is currently not scheduled for releaseWork that is important, but is currently not scheduled for releaseperf/memory-leak 💦Memory usage grows / objects live forever (sub: perf)Memory usage grows / objects live forever (sub: perf)platform/windows
Milestone
Description
This issue has been moved from a ticket on Developer Community.
namespace MauiListView
{
public class Message
{
public string? Content { get; set; }
public DateTime Timestamp { get; set; }
}
public partial class MainPage : ContentPage
{
private const int MAX_MESSAGES = 20;
private List<Message> messages;
private CancellationTokenSource? cancellationTokenSource;
public MainPage()
{
InitializeComponent();
messages = new List<Message>();
MessageListView.ItemsSource = messages;
StartMessageGeneration();
}
private async void StartMessageGeneration()
{
cancellationTokenSource = new CancellationTokenSource();
try
{
while (!cancellationTokenSource.Token.IsCancellationRequested)
{
AddMessage($"새로운 메시지 {DateTime.Now}");
await Task.Delay(1000, cancellationTokenSource.Token);
}
}
catch (OperationCanceledException)
{
}
}
private void AddMessage(string content)
{
MainThread.BeginInvokeOnMainThread(() =>
{
var message = new Message
{
Content = content,
Timestamp = DateTime.Now
};
messages.Insert(0, message);
while (messages.Count > MAX_MESSAGES)
{
messages.RemoveAt(messages.Count - 1);
}
MessageListView.ItemsSource = null;
MessageListView.ItemsSource = messages;
});
}
protected override void OnDisappearing()
{
base.OnDisappearing();
cancellationTokenSource?.Cancel();
}
}
}
Original Comments
Feedback Bot on 1/22/2025, 11:32 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Metadata
Metadata
Assignees
Labels
area-controls-listviewListView and TableViewListView and TableViewp/2Work that is important, but is currently not scheduled for releaseWork that is important, but is currently not scheduled for releaseperf/memory-leak 💦Memory usage grows / objects live forever (sub: perf)Memory usage grows / objects live forever (sub: perf)platform/windows